Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@php-wasm/scopes

Package Overview
Dependencies
Maintainers
8
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@php-wasm/scopes - npm Package Compare versions

Comparing version
3.1.28
to
3.1.29
+81
lib/scope.d.ts
/**
* Scopes are unique strings, like `my-site`, used to uniquely brand
* the outgoing HTTP traffic from each browser tab. This helps the
* main thread distinguish between the relevant and irrelevant
* messages received from the Service Worker.
*
* Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:
*
* An **unscoped** URL: http://localhost:8778/wp-login.php
* A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php
*
* For more information, see the README section on scopes.
*/
/**
* Checks if the given URL contains scope information.
*
* @example
* ```js
* isURLScoped(new URL('http://localhost/scope:my-site/index.php'));
* // true
*
* isURLScoped(new URL('http://localhost/index.php'));
* // false
* ```
*
* @param url The URL to check.
* @returns `true` if the URL contains scope information, `false` otherwise.
*/
export declare function isURLScoped(url: URL): boolean;
/**
* Returns the scope stored in the given URL.
*
* @example
* ```js
* getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));
* // '96253'
*
* getScopeFromURL(new URL('http://localhost/index.php'));
* // null
* ```
*
* @param url The URL.
* @returns The scope if the URL contains a scope, `null` otherwise.
*/
export declare function getURLScope(url: URL): string | null;
/**
* Returns a new URL with the requested scope information.
*
* @example
* ```js
* setURLScope(new URL('http://localhost/index.php'), 'my-site');
* // URL('http://localhost/scope:my-site/index.php')
*
* setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');
* // URL('http://localhost/scope:my-site/index.php')
*
* setURLScope(new URL('http://localhost/index.php'), null);
* // URL('http://localhost/index.php')
* ```
*
* @param url The URL to scope.
* @param scope The scope value.
* @returns A new URL with the scope information in it.
*/
export declare function setURLScope(url: URL | string, scope: string | null): URL;
/**
* Returns a new URL without any scope information.
*
* @example
* ```js
* removeURLScope(new URL('http://localhost/scope:my-site/index.php'));
* // URL('http://localhost/index.php')
*
* removeURLScope(new URL('http://localhost/index.php'));
* // URL('http://localhost/index.php')
* ```
*
* @param url The URL to remove scope information from.
* @returns A new URL without the scope information.
*/
export declare function removeURLScope(url: URL): URL;
+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"gFA6BO,SAASA,EAAYC,EAAmB,CAC9C,OAAOA,EAAI,SAAS,WAAW,SAAS,CACzC,CAiBO,SAASC,EAAYD,EAAyB,CACpD,OAAID,EAAYC,CAAG,EACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAExC,IACR,CAqBO,SAASE,EAAYF,EAAmBG,EAA2B,CACzE,IAAIC,EAAS,IAAI,IAAIJ,CAAG,EAExB,GAAID,EAAYK,CAAM,EACrB,GAAID,EAAO,CACV,MAAME,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvCC,EAAM,CAAC,EAAI,SAASF,CAAK,GACzBC,EAAO,SAAWC,EAAM,KAAK,GAAG,CACjC,MACCD,EAASE,EAAeF,CAAM,UAErBD,EAAO,CACjB,MAAMI,EAASH,EAAO,WAAa,IAAM,GAAKA,EAAO,SACrDA,EAAO,SAAW,UAAUD,CAAK,GAAGI,CAAM,EAC3C,CAEA,OAAOH,CACR,CAiBO,SAASE,EAAeN,EAAe,CAC7C,GAAI,CAACD,EAAYC,CAAG,EACnB,OAAOA,EAER,MAAMI,EAAS,IAAI,IAAIJ,CAAG,EACpBK,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvC,OAAAA,EAAO,SAAW,IAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,EACxCD,CACR"}
{"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/scopes/src/lib/scope.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"gFA6BO,SAASA,EAAYC,EAAmB,CAC9C,OAAOA,EAAI,SAAS,WAAW,SAAS,CACzC,CAiBO,SAASC,EAAYD,EAAyB,CACpD,OAAID,EAAYC,CAAG,EACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAExC,IACR,CAqBO,SAASE,EAAYF,EAAmBG,EAA2B,CACzE,IAAIC,EAAS,IAAI,IAAIJ,CAAG,EAExB,GAAID,EAAYK,CAAM,EACrB,GAAID,EAAO,CACV,MAAME,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvCC,EAAM,CAAC,EAAI,SAASF,CAAK,GACzBC,EAAO,SAAWC,EAAM,KAAK,GAAG,CACjC,MACCD,EAASE,EAAeF,CAAM,UAErBD,EAAO,CACjB,MAAMI,EAASH,EAAO,WAAa,IAAM,GAAKA,EAAO,SACrDA,EAAO,SAAW,UAAUD,CAAK,GAAGI,CAAM,EAC3C,CAEA,OAAOH,CACR,CAiBO,SAASE,EAAeN,EAAe,CAC7C,GAAI,CAACD,EAAYC,CAAG,EACnB,OAAOA,EAER,MAAMI,EAAS,IAAI,IAAIJ,CAAG,EACpBK,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvC,OAAAA,EAAO,SAAW,IAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,EACxCD,CACR"}

@@ -1,81 +0,1 @@

/**
* Scopes are unique strings, like `my-site`, used to uniquely brand
* the outgoing HTTP traffic from each browser tab. This helps the
* main thread distinguish between the relevant and irrelevant
* messages received from the Service Worker.
*
* Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:
*
* An **unscoped** URL: http://localhost:8778/wp-login.php
* A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php
*
* For more information, see the README section on scopes.
*/
/**
* Checks if the given URL contains scope information.
*
* @example
* ```js
* isURLScoped(new URL('http://localhost/scope:my-site/index.php'));
* // true
*
* isURLScoped(new URL('http://localhost/index.php'));
* // false
* ```
*
* @param url The URL to check.
* @returns `true` if the URL contains scope information, `false` otherwise.
*/
export declare function isURLScoped(url: URL): boolean;
/**
* Returns the scope stored in the given URL.
*
* @example
* ```js
* getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));
* // '96253'
*
* getScopeFromURL(new URL('http://localhost/index.php'));
* // null
* ```
*
* @param url The URL.
* @returns The scope if the URL contains a scope, `null` otherwise.
*/
export declare function getURLScope(url: URL): string | null;
/**
* Returns a new URL with the requested scope information.
*
* @example
* ```js
* setURLScope(new URL('http://localhost/index.php'), 'my-site');
* // URL('http://localhost/scope:my-site/index.php')
*
* setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');
* // URL('http://localhost/scope:my-site/index.php')
*
* setURLScope(new URL('http://localhost/index.php'), null);
* // URL('http://localhost/index.php')
* ```
*
* @param url The URL to scope.
* @param scope The scope value.
* @returns A new URL with the scope information in it.
*/
export declare function setURLScope(url: URL | string, scope: string | null): URL;
/**
* Returns a new URL without any scope information.
*
* @example
* ```js
* removeURLScope(new URL('http://localhost/scope:my-site/index.php'));
* // URL('http://localhost/index.php')
*
* removeURLScope(new URL('http://localhost/index.php'));
* // URL('http://localhost/index.php')
* ```
*
* @param url The URL to remove scope information from.
* @returns A new URL without the scope information.
*/
export declare function removeURLScope(url: URL): URL;
export * from './lib/scope';

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"AA6BO,SAASA,EAAYC,GAAmB;AAC9C,SAAOA,EAAI,SAAS,WAAW,SAAS;AACzC;AAiBO,SAASC,EAAYD,GAAyB;AACpD,SAAID,EAAYC,CAAG,IACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,IAExC;AACR;AAqBO,SAASE,EAAYF,GAAmBG,GAA2B;AACzE,MAAIC,IAAS,IAAI,IAAIJ,CAAG;AAExB,MAAID,EAAYK,CAAM;AACrB,QAAID,GAAO;AACV,YAAME,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,MAAAC,EAAM,CAAC,IAAI,SAASF,CAAK,IACzBC,EAAO,WAAWC,EAAM,KAAK,GAAG;AAAA,IACjC;AACC,MAAAD,IAASE,EAAeF,CAAM;AAAA,WAErBD,GAAO;AACjB,UAAMI,IAASH,EAAO,aAAa,MAAM,KAAKA,EAAO;AACrD,IAAAA,EAAO,WAAW,UAAUD,CAAK,GAAGI,CAAM;AAAA,EAC3C;AAEA,SAAOH;AACR;AAiBO,SAASE,EAAeN,GAAe;AAC7C,MAAI,CAACD,EAAYC,CAAG;AACnB,WAAOA;AAER,QAAMI,IAAS,IAAI,IAAIJ,CAAG,GACpBK,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,SAAAA,EAAO,WAAW,MAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,GACxCD;AACR;"}
{"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/scopes/src/lib/scope.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"AA6BO,SAASA,EAAYC,GAAmB;AAC9C,SAAOA,EAAI,SAAS,WAAW,SAAS;AACzC;AAiBO,SAASC,EAAYD,GAAyB;AACpD,SAAID,EAAYC,CAAG,IACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,IAExC;AACR;AAqBO,SAASE,EAAYF,GAAmBG,GAA2B;AACzE,MAAIC,IAAS,IAAI,IAAIJ,CAAG;AAExB,MAAID,EAAYK,CAAM;AACrB,QAAID,GAAO;AACV,YAAME,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,MAAAC,EAAM,CAAC,IAAI,SAASF,CAAK,IACzBC,EAAO,WAAWC,EAAM,KAAK,GAAG;AAAA,IACjC;AACC,MAAAD,IAASE,EAAeF,CAAM;AAAA,WAErBD,GAAO;AACjB,UAAMI,IAASH,EAAO,aAAa,MAAM,KAAKA,EAAO;AACrD,IAAAA,EAAO,WAAW,UAAUD,CAAK,GAAGI,CAAM;AAAA,EAC3C;AAEA,SAAOH;AACR;AAiBO,SAASE,EAAeN,GAAe;AAC7C,MAAI,CAACD,EAAYC,CAAG;AACnB,WAAOA;AAER,QAAMI,IAAS,IAAI,IAAIJ,CAAG,GACpBK,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,SAAAA,EAAO,WAAW,MAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,GACxCD;AACR;"}
{
"name": "@php-wasm/scopes",
"version": "3.1.28",
"version": "3.1.29",
"description": "PHP.wasm – scoped URLs utils",

@@ -35,3 +35,3 @@ "repository": {

"types": "index.d.ts",
"gitHead": "1f7287114a99a7560576b49108c2af09402ccb9b",
"gitHead": "39c1c459c1c4dd360ad0da011a15cd2f12514c8a",
"engines": {

@@ -38,0 +38,0 @@ "node": ">=20.10.0",