sociallinks.dev

બ્લોગ / ડેવલપર ગાઇડ

સોશિયલ મીડિયા પ્રોફાઇલ URL કેવી રીતે parse અને નૉર્મલાઇઝ કરવાં (Instagram, TikTok, YouTube, X)

ક્રિએટર પોતાની પ્રોફાઇલ લિંક દરેક કલ્પી શકાય તેવા રૂપમાં પેસ્ટ કરે છે: www સાથે અને વિના, ટ્રૅકિંગ પેરામીટરવાળી મોબાઇલ એપમાંથી, short link તરીકે, જૂના twitter.com URL તરીકે, કે પ્રોફાઇલને બદલે પોસ્ટની લિંક તરીકે. જો તમારી પ્રોડક્ટ આ strings જેવી આવે તેવી જ રાખે, તો એક જ ક્રિએટર ત્રણ વાર દેખાય છે અને તમારા joins ચૂપચાપ ચૂકી જાય છે. આ માર્ગદર્શિકા બતાવે છે કે કોઈ પણ Instagram, TikTok, YouTube કે X પ્રોફાઇલ URL ને પ્લેટફોર્મ, હેન્ડલ કે channel ID, અને એક canonical URL માં કેવી રીતે ફેરવવું, JavaScript અને Python માં ચકાસાયેલા કોડ સાથે.

પ્રોફાઇલ URL નૉર્મલાઇઝ કરવાં કેમ મહત્વનાં છે

પ્રોફાઇલ URL એક identifier છે, અને identifier ત્યારે જ કામ કરે જ્યારે તે એક જ રીતે લખાય. https://www.instagram.com/natgeo/, instagram.com/NatGeo?igsh=MWQ1ZGUxMzBkMA== અને https://m.instagram.com/natgeo બધાં એક જ એકાઉન્ટ તરફ જાય છે, પણ strings તરીકે તે ત્રણ જુદાં મૂલ્યો છે.

લક્ષ્ય છે એક નાનું, કડક function: તે યુઝર ખરેખર જે પેસ્ટ કરે તે સ્વીકારે, સાચાં પ્રોફાઇલ URL માટે નૉર્મલાઇઝ્ડ પરિણામ આપે, અને બાકી બધા માટે null આપે.

તમને જોવા મળશે તેવાં URL રૂપ

નીચેનાં રૂપ October 2026 માં live સાઇટ્સ સામે તપાસ્યાં હતાં. પ્લેટફોર્મ જાણ કર્યા વિના routing બદલે છે, તેથી આને એક snapshot ગણો અને તમારા test cases અપડેટ રાખો.

Instagram

TikTok

YouTube

X (પહેલાં Twitter)

દરેક પ્લેટફોર્મ માટે હેન્ડલના અક્ષરોના નિયમો

હેન્ડલ validate કરવાથી typos અને મોટાભાગના બિન-પ્રોફાઇલ paths પકડાય છે. પ્લેટફોર્મ પોતાના નિયમો પ્રકાશિત કરે ત્યાં તે વાપરો, અને ન કરે ત્યાં તપાસ ઢીલી રાખો, જેથી તમે ક્યારેય સાચું એકાઉન્ટ નકારો નહીં.

પ્લેટફોર્મમંજૂર અક્ષરોલંબાઈCaseસ્રોત
Instagramઅક્ષરો, અંકો, periods, underscores30 નો વ્યાપક ઉલ્લેખ થાય છે; Instagram નાં help pages માં મળ્યું નથીCase-insensitive ગણો; નાના અક્ષરમાં રાખોInstagram Help Center periods, અંકો અને underscores નો ઉલ્લેખ કરે છે
TikTokઅક્ષરો, અંકો, underscores, periods; period થી અંત ન થઈ શકે2 થી 24URL માં case-insensitive (@TikTok tiktok પર ખૂલે છે)TikTok Support, username બદલવા વિશે
YouTubeSupport થતી ભાષાઓના અક્ષરો કે અંકો, અને underscores, hyphens, periods અને Latin middle dots (પહેલા કે છેલ્લા નહીં)મોટાભાગની લિપિ માટે 3 થી 30; Han, Hangul અને કેટલીક બીજી લિપિ માટે ટૂંકી મર્યાદાCase-sensitive નથીYouTube Help, હેન્ડલ માર્ગદર્શિકા
Xઅક્ષરો, અંકો અને underscores15 સુધી; નવાં usernames 4 થી લાંબાં હોવાં જોઈએ, પણ જૂનાં ટૂંકાં હેન્ડલ અસ્તિત્વમાં છેCase-sensitive નથી (x.com/JACK canonical રૂપે x.com/jack બને છે)X Help Center, username ના નિયમો

નૉર્મલાઇઝેશનનો algorithm

  1. Step 1Trim કરો અને scheme ઉમેરો

    Whitespace અને છૂટાં angle brackets કાઢો. જો ઇનપુટમાં scheme ન હોય, તો આગળ https:// લગાવો જેથી instagram.com/natgeo parse થાય.

  2. Step 2સાચા URL parser થી parse કરો

    JavaScript માં new URL() કે Python માં urllib.parse.urlsplit વાપરો, આખી string પર regex ક્યારેય નહીં. Parser ports, user info અને encoded અક્ષરો સંભાળે છે, અને https://instagram.com@evil.com/natgeo ને Instagram તરીકે પસાર થતું અટકાવે છે.

  3. Step 3Host નૉર્મલાઇઝ કરો

    તેને નાના અક્ષરમાં ફેરવો અને આગળનો એક www., m. કે mobile. કાઢો. પછી તેને hosts ની ચોક્કસ allow-list માં શોધો. includes("instagram.com") ક્યારેય ન વાપરો, જે instagram.com.evil.com સાથે પણ મેળ ખાય છે.

  4. Step 4Query string અને fragment કાઢો

    igsh, s, t અને lang જેવા ટ્રૅકિંગ પેરામીટર URL કઈ પ્રોફાઇલ તરફ જાય છે તે ક્યારેય બદલતા નથી.

  5. Step 5Path વિભાજિત કરો અને decode કરો

    / પર વિભાજિત કરો, ખાલી segments કાઢો (આથી છેલ્લા slashes દૂર થાય છે) અને દરેકને percent-decode કરો. ખોટા encoding ને અમાન્ય ઇનપુટ ગણો.

  6. Step 6પ્લેટફોર્મ મુજબ route કરો

    દરેક પ્લેટફોર્મનું રૂપ લાગુ કરો: Instagram અને X પર એક segment, TikTok પર @ segment, અને YouTube પર @handle, channel/UC..., user/name કે c/name. Reserved શબ્દો નકારો.

  7. Step 7હેન્ડલ validate કરો અને નાના અક્ષરમાં ફેરવો

    પ્લેટફોર્મના અક્ષર નિયમો સામે હેન્ડલ તપાસો, પછી તેને નાના અક્ષરમાં ફેરવો. YouTube channel ID ને નાના અક્ષરમાં ન ફેરવો: તે case-sensitive છે.

  8. Step 8Canonical URL બનાવો

    એક નક્કી host પર ભાગો પરથી URL ફરી બનાવો, જેથી દરેક સમાન ઇનપુટ બરાબર એક જ string આપે.

  9. Step 9Short links અલગથી સંભાળો

    TikTok short links ઓળખો, HTTP request થી redirect અનુસરો, અને અંતિમ URL ફરી parser માંથી પસાર કરો. આને pure function ની બહાર રાખો જેથી parsing ઝડપી અને test કરી શકાય તેવું રહે.

JavaScript અને Python માં કોડ

બંને functions એક જ ઇનપુટ માટે એક જ objects આપે છે: હેન્ડલ URL માટે { platform, handle, canonicalUrl }, YouTube channel ID માટે { platform, channelId, canonicalUrl }, YouTube નાં બે જૂનાં રૂપ માટે username કે customName, અને પ્રોફાઇલ URL ન હોય તેવી દરેક વસ્તુ માટે null. બેમાંથી કોઈને dependency જોઈતી નથી.

JavaScript (Node 18+)

Node.js

const HOSTS = {
  "instagram.com": "instagram",
  "tiktok.com": "tiktok",
  "youtube.com": "youtube",
  "x.com": "x",
  "twitter.com": "x",
};

const IG_RESERVED = new Set(["p", "reel", "reels", "tv", "stories", "explore", "accounts", "direct"]);
const X_RESERVED = new Set([
  "home", "explore", "search", "i", "settings", "notifications", "messages",
  "compose", "intent", "hashtag", "login", "signup", "logout", "tos", "privacy",
]);

const IG_HANDLE = /^[a-z0-9._]{1,30}$/;
const TIKTOK_HANDLE = /^[a-z0-9._]{2,24}$/;
const X_HANDLE = /^[a-z0-9_]{1,15}$/;
const YT_HANDLE = /^[\p{L}\p{M}\p{N}._\-·]{1,30}$/u;
const YT_CHANNEL_ID = /^UC[A-Za-z0-9_-]{22}$/;
const YT_LEGACY_NAME = /^[A-Za-z0-9._-]{1,100}$/;

export function parseProfileUrl(input) {
  if (typeof input !== "string") return null;
  let raw = input.trim().replace(/^<|>$/g, "");
  if (!raw) return null;
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) raw = "https://" + raw;

  let url;
  try {
    url = new URL(raw);
  } catch {
    return null;
  }
  if (url.protocol !== "https:" && url.protocol !== "http:") return null;

  const host = url.hostname.toLowerCase().replace(/^(www|m|mobile)\./, "");
  const platform = HOSTS[host];
  if (!platform) return null;

  let segments;
  try {
    segments = url.pathname.split("/").filter(Boolean).map(decodeURIComponent);
  } catch {
    return null; // malformed percent-encoding
  }
  const [first = "", second] = segments;

  if (platform === "instagram") {
    const handle = first.toLowerCase();
    if (segments.length !== 1 || IG_RESERVED.has(handle) || !IG_HANDLE.test(handle)) return null;
    return { platform, handle, canonicalUrl: `https://www.instagram.com/${handle}/` };
  }

  if (platform === "tiktok") {
    if (segments.length !== 1 || !first.startsWith("@")) return null;
    const handle = first.slice(1).toLowerCase();
    if (!TIKTOK_HANDLE.test(handle) || handle.endsWith(".")) return null;
    return { platform, handle, canonicalUrl: `https://www.tiktok.com/@${handle}` };
  }

  if (platform === "x") {
    const handle = first.toLowerCase();
    if (segments.length !== 1 || X_RESERVED.has(handle) || !X_HANDLE.test(handle)) return null;
    return { platform, handle, canonicalUrl: `https://x.com/${handle}` };
  }

  // YouTube: /@handle[/tab], /channel/UC...[/tab], /user/name, /c/name
  if (first.startsWith("@")) {
    const handle = first.slice(1).toLowerCase();
    if (!YT_HANDLE.test(handle) || /^[._\-·]|[._\-·]$/.test(handle)) return null;
    return { platform, handle, canonicalUrl: `https://www.youtube.com/@${encodeURIComponent(handle)}` };
  }
  if (first === "channel" && second && YT_CHANNEL_ID.test(second)) {
    return { platform, channelId: second, canonicalUrl: `https://www.youtube.com/channel/${second}` };
  }
  if ((first === "user" || first === "c") && second && segments.length === 2 && YT_LEGACY_NAME.test(second)) {
    const key = first === "user" ? "username" : "customName";
    return { platform, [key]: second, canonicalUrl: `https://www.youtube.com/${first}/${second}` };
  }
  return null; // videos, shorts, playlists, search and anything else
}

const SHORT_HOSTS = new Set(["vm.tiktok.com", "vt.tiktok.com"]);

export function isShortLink(input) {
  try {
    const url = new URL(/^https?:\/\//i.test(input) ? input : "https://" + input);
    const host = url.hostname.toLowerCase();
    return SHORT_HOSTS.has(host) || (host.replace(/^www\./, "") === "tiktok.com" && url.pathname.startsWith("/t/"));
  } catch {
    return false;
  }
}

export async function resolveShortLink(input) {
  const res = await fetch(/^https?:\/\//i.test(input) ? input : "https://" + input, {
    redirect: "follow",
    signal: AbortSignal.timeout(10_000),
  });
  await res.body?.cancel();
  return res.url; // the final URL after every redirect
}

resolveShortLink બિલ્ટ-ઇન fetch વાપરે છે, જે redirects અનુસરે છે અને અંતિમ સરનામું res.url તરીકે આપે છે. જ્યારે isShortLink(link) true હોય ત્યારે parseProfileUrl(await resolveShortLink(link)) call કરો. Short link પ્રોફાઇલને બદલે વીડિયો તરફ પણ લઈ જઈ શકે, અને ત્યારે parser યોગ્ય રીતે null આપે છે.

Python 3

Python

import re
import unicodedata
import urllib.request
from urllib.parse import quote, unquote, urlsplit

HOSTS = {
    "instagram.com": "instagram",
    "tiktok.com": "tiktok",
    "youtube.com": "youtube",
    "x.com": "x",
    "twitter.com": "x",
}

IG_RESERVED = {"p", "reel", "reels", "tv", "stories", "explore", "accounts", "direct"}
X_RESERVED = {
    "home", "explore", "search", "i", "settings", "notifications", "messages",
    "compose", "intent", "hashtag", "login", "signup", "logout", "tos", "privacy",
}

IG_HANDLE = re.compile(r"[a-z0-9._]{1,30}")
TIKTOK_HANDLE = re.compile(r"[a-z0-9._]{2,24}")
X_HANDLE = re.compile(r"[a-z0-9_]{1,15}")
YT_CHANNEL_ID = re.compile(r"UC[A-Za-z0-9_-]{22}")
YT_LEGACY_NAME = re.compile(r"[A-Za-z0-9._-]{1,100}")
YT_PUNCT = "._-·"


def _is_youtube_handle(handle):
    if not 1 <= len(handle) <= 30 or handle[0] in YT_PUNCT or handle[-1] in YT_PUNCT:
        return False
    return all(
        ch.isalnum() or ch in YT_PUNCT or unicodedata.category(ch).startswith("M")
        for ch in handle
    )


def parse_profile_url(value):
    if not isinstance(value, str):
        return None
    raw = value.strip().strip("<>")
    if not raw:
        return None
    if not re.match(r"^[a-z][a-z0-9+.-]*://", raw, re.I):
        raw = "https://" + raw

    try:
        url = urlsplit(raw)
        host = (url.hostname or "").lower()
    except ValueError:
        return None
    if url.scheme.lower() not in ("http", "https"):
        return None

    host = re.sub(r"^(www|m|mobile)\.", "", host)
    platform = HOSTS.get(host)
    if not platform:
        return None

    try:
        segments = [unquote(s, errors="strict") for s in url.path.split("/") if s]
    except UnicodeDecodeError:
        return None  # malformed percent-encoding
    first = segments[0] if segments else ""
    second = segments[1] if len(segments) > 1 else None

    if platform == "instagram":
        handle = first.lower()
        if len(segments) != 1 or handle in IG_RESERVED or not IG_HANDLE.fullmatch(handle):
            return None
        return {"platform": platform, "handle": handle,
                "canonicalUrl": f"https://www.instagram.com/{handle}/"}

    if platform == "tiktok":
        if len(segments) != 1 or not first.startswith("@"):
            return None
        handle = first[1:].lower()
        if not TIKTOK_HANDLE.fullmatch(handle) or handle.endswith("."):
            return None
        return {"platform": platform, "handle": handle,
                "canonicalUrl": f"https://www.tiktok.com/@{handle}"}

    if platform == "x":
        handle = first.lower()
        if len(segments) != 1 or handle in X_RESERVED or not X_HANDLE.fullmatch(handle):
            return None
        return {"platform": platform, "handle": handle, "canonicalUrl": f"https://x.com/{handle}"}

    # YouTube: /@handle[/tab], /channel/UC...[/tab], /user/name, /c/name
    if first.startswith("@"):
        handle = first[1:].lower()
        if not _is_youtube_handle(handle):
            return None
        return {"platform": platform, "handle": handle,
                "canonicalUrl": f"https://www.youtube.com/@{quote(handle, safe='._-')}"}
    if first == "channel" and second and YT_CHANNEL_ID.fullmatch(second):
        return {"platform": platform, "channelId": second,
                "canonicalUrl": f"https://www.youtube.com/channel/{second}"}
    if first in ("user", "c") and second and len(segments) == 2 and YT_LEGACY_NAME.fullmatch(second):
        key = "username" if first == "user" else "customName"
        return {"platform": platform, key: second,
                "canonicalUrl": f"https://www.youtube.com/{first}/{second}"}
    return None  # videos, shorts, playlists, search and anything else


SHORT_HOSTS = {"vm.tiktok.com", "vt.tiktok.com"}


def is_short_link(value):
    url = urlsplit(value if re.match(r"^https?://", value, re.I) else "https://" + value)
    host = (url.hostname or "").lower()
    return host in SHORT_HOSTS or (
        re.sub(r"^www\.", "", host) == "tiktok.com" and url.path.startswith("/t/")
    )


def resolve_short_link(value, timeout=10):
    if not re.match(r"^https?://", value, re.I):
        value = "https://" + value
    request = urllib.request.Request(value, headers={"User-Agent": "Mozilla/5.0"})
    with urllib.request.urlopen(request, timeout=timeout) as response:
        return response.geturl()  # the final URL after every redirect

Python નાં \w અને str.isalnum() Unicode અક્ષરો અને અંકો આવરે છે, પણ Devanagari જેવી લિપિમાં વપરાતા combining marks નહીં, તેથી YouTube ની તપાસ Unicode ની M શ્રેણીના અક્ષરો પણ સ્વીકારે છે.

Edge cases અને tests

નીચેની દરેક હરોળ test suite નો ભાગ છે જે બંને implementations પાસ કરે છે.

ઇનપુટઆઉટપુટકેમ
instagram.com/NatGeo?igsh=MWQ1ZGUxMzBkMA==instagram, natgeo, https://www.instagram.com/natgeo/Scheme નથી, મિશ્ર case, share પેરામીટર
https://m.instagram.com/nat.geo_/#bioinstagram, nat.geo_મોબાઇલ host અને fragment
https://www.instagram.com/p/C9xYzAbCdEf/nullપોસ્ટ, પ્રોફાઇલ નહીં
https://www.instagram.com/stories/natgeo/1234567890/nullStory, ભલે path માં હેન્ડલ હોય
tiktok.com/@Khaby.Lame/tiktok, khaby.lame, https://www.tiktok.com/@khaby.lameછેલ્લો slash અને case
https://www.tiktok.com/@khaby.lame/video/7106594312292453675nullવીડિયો URL
https://vm.tiktok.com/ZMabc123/null (પહેલાં redirect અનુસરો)હેન્ડલ વિનાની short link
https://m.youtube.com/@GoogleDevelopers/videos?app=desktopyoutube, googledevelopersમોબાઇલ host, ચેનલ ટૅબ, query
https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw/featuredyoutube, channelId UC_x5XG1OV2P6uZZ5FSM9TtwChannel ID પોતાનો case રાખે છે
https://www.youtube.com/c/GoogleDevelopersyoutube, customName GoogleDevelopersજૂનું custom URL; ID માટે lookup જોઈએ
https://www.youtube.com/@%E3%83%86%E3%82%B9%E3%83%88youtube, હેન્ડલ テストPercent-encoded Unicode હેન્ડલ
https://youtu.be/dQw4w9WgXcQnullવીડિયો, ચેનલ નહીં
https://mobile.twitter.com/jack?s=21&t=abcx, jack, https://x.com/jackજૂનું domain અને share પેરામીટર
https://x.com/i/flow/loginnullApp route
https://x.com/this_handle_is_too_longnull15 થી વધુ અક્ષર
https://instagram.com.evil.com/natgeonullમળતો આવતો host
https://instagram.com@evil.com/natgeonullUser info ની યુક્તિ; સાચો host evil.com છે
@natgeonullખાલી હેન્ડલનું કોઈ પ્લેટફોર્મ નથી

Cases તમારી repository માં રાખો અને CI માં ચલાવો. જ્યારે કોઈ પ્લેટફોર્મ નવો route કે share પેરામીટર ઉમેરે, ત્યારે તમે એક હરોળ ઉમેરો છો અને સુધારો સ્પષ્ટ દેખાય છે.

Node.js test

import assert from "node:assert/strict";
import { parseProfileUrl } from "./parse.mjs";

const cases = [
  ["instagram.com/NatGeo?igsh=MWQ1ZGUxMzBkMA==", { platform: "instagram", handle: "natgeo", canonicalUrl: "https://www.instagram.com/natgeo/" }],
  ["https://www.instagram.com/reel/C9xYzAbCdEf/", null],
  ["https://www.instagram.com/explore/", null],
  ["tiktok.com/@Khaby.Lame/", { platform: "tiktok", handle: "khaby.lame", canonicalUrl: "https://www.tiktok.com/@khaby.lame" }],
  ["https://www.tiktok.com/@khaby.lame/video/7106594312292453675", null],
  ["https://vm.tiktok.com/ZMabc123/", null],
  ["https://m.youtube.com/@GoogleDevelopers/videos", { platform: "youtube", handle: "googledevelopers", canonicalUrl: "https://www.youtube.com/@googledevelopers" }],
  ["https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw/featured", { platform: "youtube", channelId: "UC_x5XG1OV2P6uZZ5FSM9Ttw", canonicalUrl: "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw" }],
  ["https://www.youtube.com/user/GoogleDevelopers", { platform: "youtube", username: "GoogleDevelopers", canonicalUrl: "https://www.youtube.com/user/GoogleDevelopers" }],
  ["https://youtu.be/dQw4w9WgXcQ", null],
  ["https://twitter.com/Jack/", { platform: "x", handle: "jack", canonicalUrl: "https://x.com/jack" }],
  ["https://mobile.twitter.com/jack?s=21", { platform: "x", handle: "jack", canonicalUrl: "https://x.com/jack" }],
  ["https://x.com/jack/status/20", null],
  ["https://x.com/i/flow/login", null],
  ["https://instagram.com.evil.com/natgeo", null],
];

for (const [input, expected] of cases) {
  assert.deepEqual(parseProfileUrl(input), expected, input);
}
console.log(`${cases.length} cases passed`);

Python test

from parse_profile import parse_profile_url

CASES = [
    ("instagram.com/NatGeo?igsh=MWQ1ZGUxMzBkMA==", {"platform": "instagram", "handle": "natgeo", "canonicalUrl": "https://www.instagram.com/natgeo/"}),
    ("https://www.instagram.com/reel/C9xYzAbCdEf/", None),
    ("tiktok.com/@Khaby.Lame/", {"platform": "tiktok", "handle": "khaby.lame", "canonicalUrl": "https://www.tiktok.com/@khaby.lame"}),
    ("https://vm.tiktok.com/ZMabc123/", None),
    ("https://m.youtube.com/@GoogleDevelopers/videos", {"platform": "youtube", "handle": "googledevelopers", "canonicalUrl": "https://www.youtube.com/@googledevelopers"}),
    ("https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw/featured", {"platform": "youtube", "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw", "canonicalUrl": "https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw"}),
    ("https://youtu.be/dQw4w9WgXcQ", None),
    ("https://twitter.com/Jack/", {"platform": "x", "handle": "jack", "canonicalUrl": "https://x.com/jack"}),
    ("https://x.com/i/flow/login", None),
    ("https://instagram.com.evil.com/natgeo", None),
]

for value, expected in CASES:
    assert parse_profile_url(value) == expected, value
print(f"{len(CASES)} cases passed")

મૂળ ઇનપુટ અને canonical રૂપ બંને રાખો

નૉર્મલાઇઝેશન રચનાથી જ માહિતી ગુમાવે છે, અને તમારા નિયમો સમય સાથે સુધરશે. બંને મૂલ્યો રાખો:

હેન્ડલ કાયમી નથી. ક્રિએટર દરેક પ્લેટફોર્મ પર એકાઉન્ટનાં નામ બદલે છે, અને ગયા વર્ષે રાખેલું હેન્ડલ હવે કોઈ બીજાનું હોઈ શકે. જ્યાં સત્તાવાર API સ્થિર ID આપે, જેમ કે YouTube channel ID, ત્યાં તેને લાંબા ગાળાની key તરીકે રાખો અને હેન્ડલને display value ગણો જે તમે રિફ્રેશ કરો. હેન્ડલ પરથી YouTube channel ID મેળવવા વિશેની સાથી માર્ગદર્શિકા બતાવે છે કે કેવી રીતે.

એક પ્રોફાઇલ પરથી બીજી પ્રોફાઇલ સુધી

પ્રોફાઇલ URL નૉર્મલાઇઝ થયા પછી, પછીનો પ્રશ્ન સામાન્ય રીતે એ હોય છે કે એ જ ક્રિએટરનાં બીજાં કયાં એકાઉન્ટ છે. sociallinks.dev એક API છે જે એક Instagram, TikTok, YouTube કે X પ્રોફાઇલ URL લે છે અને ક્રિએટરનાં બીજાં પ્લેટફોર્મ પરનાં એકાઉન્ટ, દરેક મેળ માટે confidence score અને પુરાવા સાથે આપે છે.

વારંવાર પૂછાતા પ્રશ્નો

શું હેન્ડલ રાખતા પહેલાં તેને નાના અક્ષરમાં ફેરવવાં જોઈએ?

Lookup key માટે હા. YouTube અને X કહે છે કે હેન્ડલ case-sensitive નથી, અને TikTok @TikTok ને @tiktok જેવા જ એકાઉન્ટ પર ખોલે છે. Instagram case નો નિયમ દસ્તાવેજિત નથી કરતું, પણ usernames નાના અક્ષરમાં દેખાય છે, તેથી નાના અક્ષર સુરક્ષિત default છે. બતાવવા માગતા હો તો મૂળ casing raw URL માં રાખો. YouTube channel ID ને નાના અક્ષરમાં ન ફેરવો, તે case-sensitive છે.

શું પોસ્ટ કે વીડિયો URL પરથી હેન્ડલ કાઢી શકાય?

TikTok વીડિયો (/@handle/video/id) અને X પોસ્ટ (/handle/status/id) માટે path માંનું હેન્ડલ લેખકનું છે, તેથી તમને તે જોઈતું હોય તો કાઢી શકો. Instagram પોસ્ટ અને reel URL (/p/ અને /reel/) માં હેન્ડલ નથી હોતું. આ માર્ગદર્શિકાનાં functions આ બધા માટે null આપે છે કારણ કે તે પ્રોફાઇલ લિંક નથી.

vm.tiktok.com લિંક કેવી રીતે સંભાળવી?

Short links માં માત્ર એક code હોય છે. HTTP request કરો, redirects અનુસરો, અને અંતિમ URL parse કરો. તે timeout અને cache સાથે અલગ પગલામાં કરો, કારણ કે તે network call છે અને code expire થઈ શકે.

શું twitter.com હજી માન્ય પ્રોફાઇલ URL છે?

હા. twitter.com પ્રોફાઇલ URL x.com પર redirect થાય છે, તેથી બંને domain ને X પ્લેટફોર્મ ગણો અને x.com રૂપને canonical તરીકે રાખો.

એક મોટું regular expression કેમ ન વાપરવું?

આખી string પર એક regex વાંચવું મુશ્કેલ છે અને મળતા આવતા hosts, user info કે encoded અક્ષરોથી સહેલાઈથી છેતરાય છે. પહેલાં standard library થી URL parse કરો, પછી માત્ર હેન્ડલ પર નાનાં regex વાપરો.

YouTube /c/ કે /user/ URL ને channel ID માં કેવી રીતે ફેરવવું?

/user/<name> URL YouTube Data API ના forUsername filter સાથે મેળ ખાય છે. /c/ custom નામ માટે કોઈ API filter નથી. બંને કિસ્સા માટે હેન્ડલ પરથી YouTube channel ID મેળવવા વિશેની માર્ગદર્શિકા જુઓ.

ક્રિએટરના એકાઉન્ટ શોધો