Function: extractReferralCodeFromUrl()
extractReferralCodeFromUrl(
input,paramName?):string|null
Extract a referral code from a URL or a search string.
Accepts a full or relative URL (https://shop.example/register?ref=CODE,
/register?ref=CODE), a search string starting with ? (?ref=CODE) or a
URL instance. Returns the trimmed code, or null when the parameter is
absent, empty, longer than REFERRAL_CODE_MAX_LENGTH or outside
REFERRAL_CODE_PATTERN (such values would be ignored by the API
anyway, so they are never persisted).
Parameters
input
string | URL
URL, URL instance or ?-prefixed search string to inspect.
paramName?
string = 'ref'
Query parameter carrying the code (default 'ref' —
matches the share links generated by the platform).
Returns
string | null