@helpers4/url 2.0.0-alpha.15 → 2.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/llms.txt +1 -1
- package/meta/api.json +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -94,7 +94,7 @@ function onlyPath(url) {
|
|
|
94
94
|
*/
|
|
95
95
|
function withoutTrailingSlash(url) {
|
|
96
96
|
if (url === void 0 || url === null) return url;
|
|
97
|
-
return url
|
|
97
|
+
return url.replace(/\/+$/, "");
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region helpers/url/withLeadingSlash.ts
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../helpers/url/cleanPath.ts","../../../helpers/url/extractPureURI.ts","../../../helpers/url/onlyPath.ts","../../../helpers/url/withoutTrailingSlash.ts","../../../helpers/url/withLeadingSlash.ts","../../../helpers/url/relativeURLToAbsolute.ts","../../../helpers/url/withTrailingSlash.ts","../../../helpers/url/withoutLeadingSlash.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Clean an URL by removing duplicate slashes.\n * The protocol part of the URL is not modified.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The cleaned URL string, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * cleanPath('/path//to///resource') // => '/path/to/resource'\n * cleanPath('http://example.com//path//to///resource') // => 'http://example.com/path/to/resource'\n * cleanPath(undefined) // => undefined\n * cleanPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function cleanPath(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url.replace(/([^:]\\/)\\/+/g, '$1')\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\n/**\n * Extracts the pure URI from a URL by removing query parameters and fragments.\n *\n * @param url - The URL string to process\n * @returns The URI without query parameters and fragments, or the original value if undefined/null\n * @since 1.9.0\n */\nexport function extractPureURI(url: string): string;\nexport function extractPureURI(url: undefined): undefined;\nexport function extractPureURI(url: null): null;\nexport function extractPureURI(url: string | undefined | null): string | undefined | null {\n if (url === undefined || url === null) {\n return url;\n }\n\n // Find the first occurrence of ? or #\n const queryIndex = url.indexOf('?');\n const fragmentIndex = url.indexOf('#');\n\n let cutIndex = -1;\n\n if (queryIndex !== -1 && fragmentIndex !== -1) {\n // Both exist, take the earliest one\n cutIndex = Math.min(queryIndex, fragmentIndex);\n } else if (queryIndex !== -1) {\n // Only query exists\n cutIndex = queryIndex;\n } else if (fragmentIndex !== -1) {\n // Only fragment exists\n cutIndex = fragmentIndex;\n }\n\n // If no query or fragment found, return the original string\n if (cutIndex === -1) {\n return url;\n }\n\n // Return the substring up to the first ? or #\n return url.substring(0, cutIndex);\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: string): string\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: null): null\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: undefined): undefined\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n const [path] = url.split(/[?#]/)\n return path\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: string): string\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: undefined): undefined\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: null): null\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[url.length - 1] === '/' ? url.slice(0, -1) : url\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: string): string\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: undefined): undefined\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: null): null\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[0] === '/' ? url : '/' + url\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { withoutTrailingSlash } from \"./withoutTrailingSlash\";\nimport { withLeadingSlash } from \"./withLeadingSlash\";\nimport { cleanPath } from \"./cleanPath\";\n\n/**\n * Converts a relative URL to an absolute URL using the current document base URI.\n * @param relativeUrl - The relative URL to convert\n * @returns The absolute URL\n * @since 1.0.0\n */\nexport function relativeURLToAbsolute(relativeUrl: string): string {\n return (\n withoutTrailingSlash(document.baseURI ?? window.location.origin) +\n cleanPath(withLeadingSlash(relativeUrl))\n );\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: string): string\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: undefined): undefined\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: null): null\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[url.length - 1] === '/' ? url : url + '/'\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: string): string\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: undefined): undefined\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: null): null\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[0] === '/' ? url.slice(1) : url\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,UACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,QAAQ,gBAAgB,KAAK;;;;ACP1C,SAAgB,eAAe,KAA2D;AACxF,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;CAIT,MAAM,aAAa,IAAI,QAAQ,IAAI;CACnC,MAAM,gBAAgB,IAAI,QAAQ,IAAI;CAEtC,IAAI,WAAW;AAEf,KAAI,eAAe,MAAM,kBAAkB,GAEzC,YAAW,KAAK,IAAI,YAAY,cAAc;UACrC,eAAe,GAExB,YAAW;UACF,kBAAkB,GAE3B,YAAW;AAIb,KAAI,aAAa,GACf,QAAO;AAIT,QAAO,IAAI,UAAU,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuDnC,SAAgB,SACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;CAET,MAAM,CAAC,QAAQ,IAAI,MAAM,OAAO;AAChC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPT,SAAgB,qBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,IAAI,SAAS,OAAO,MAAM,IAAI,MAAM,GAAG,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;ACV1D,SAAgB,iBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,OAAO,MAAM,MAAM,MAAM;;;;;;;;;;;;;;;ACrFtC,SAAgB,sBAAsB,aAA6B;AAC/D,QACI,qBAAqB,SAAS,WAAW,OAAO,SAAS,OAAO,GAChE,UAAU,iBAAiB,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AC4EhD,SAAgB,kBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,IAAI,SAAS,OAAO,MAAM,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;ACFnD,SAAgB,oBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,OAAO,MAAM,IAAI,MAAM,EAAE,GAAG"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../helpers/url/cleanPath.ts","../../../helpers/url/extractPureURI.ts","../../../helpers/url/onlyPath.ts","../../../helpers/url/withoutTrailingSlash.ts","../../../helpers/url/withLeadingSlash.ts","../../../helpers/url/relativeURLToAbsolute.ts","../../../helpers/url/withTrailingSlash.ts","../../../helpers/url/withoutLeadingSlash.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Clean an URL by removing duplicate slashes.\n * The protocol part of the URL is not modified.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The cleaned URL string, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * cleanPath('/path//to///resource') // => '/path/to/resource'\n * cleanPath('http://example.com//path//to///resource') // => 'http://example.com/path/to/resource'\n * cleanPath(undefined) // => undefined\n * cleanPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function cleanPath(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url.replace(/([^:]\\/)\\/+/g, '$1')\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\n/**\n * Extracts the pure URI from a URL by removing query parameters and fragments.\n *\n * @param url - The URL string to process\n * @returns The URI without query parameters and fragments, or the original value if undefined/null\n * @since 1.9.0\n */\nexport function extractPureURI(url: string): string;\nexport function extractPureURI(url: undefined): undefined;\nexport function extractPureURI(url: null): null;\nexport function extractPureURI(url: string | undefined | null): string | undefined | null {\n if (url === undefined || url === null) {\n return url;\n }\n\n // Find the first occurrence of ? or #\n const queryIndex = url.indexOf('?');\n const fragmentIndex = url.indexOf('#');\n\n let cutIndex = -1;\n\n if (queryIndex !== -1 && fragmentIndex !== -1) {\n // Both exist, take the earliest one\n cutIndex = Math.min(queryIndex, fragmentIndex);\n } else if (queryIndex !== -1) {\n // Only query exists\n cutIndex = queryIndex;\n } else if (fragmentIndex !== -1) {\n // Only fragment exists\n cutIndex = fragmentIndex;\n }\n\n // If no query or fragment found, return the original string\n if (cutIndex === -1) {\n return url;\n }\n\n // Return the substring up to the first ? or #\n return url.substring(0, cutIndex);\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: string): string\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: null): null\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(url: undefined): undefined\n\n/**\n * Extract only the path from an URI with optional query and fragments.\n *\n * For example, all these parameters will return `/path`:\n * - `/path`\n * - `/path?query=thing`\n * - `/path#fragment`\n * - `/path?query=thing#fragment`\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without query and fragment, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @example\n * ```ts\n * onlyPath('/path') // => '/path'\n * onlyPath('/path?query=thing') // => '/path'\n * onlyPath('/path#fragment') // => '/path'\n * onlyPath('/path?query=thing#fragment') // => '/path'\n * onlyPath(undefined) // => undefined\n * onlyPath(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function onlyPath(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n const [path] = url.split(/[?#]/)\n return path\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: string): string\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: undefined): undefined\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(url: null): null\n\n/**\n * Removes the trailing slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutTrailingSlash\n *\n * @example\n * ```ts\n * withoutTrailingSlash('') // => ''\n * withoutTrailingSlash('/') // => ''\n * withoutTrailingSlash('no/slash/') // => 'no/slash'\n * withoutTrailingSlash('already/has/slash') // => 'already/has/slash'\n * withoutTrailingSlash(undefined) // => undefined\n * withoutTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutTrailingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url.replace(/\\/+$/, '')\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: string): string\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: undefined): undefined\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(url: null): null\n\n/**\n * Adds a leading slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withLeadingSlash\n *\n * @example\n * ```ts\n * withLeadingSlash('') // => '/'\n * withLeadingSlash('no/slash') // => '/no/slash'\n * withLeadingSlash('/already/has/slash') // => '/already/has/slash'\n * withLeadingSlash(undefined) // => undefined\n * withLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withLeadingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[0] === '/' ? url : '/' + url\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/*\n * This program is under the terms of the GNU Lesser General Public License version 3\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { withoutTrailingSlash } from \"./withoutTrailingSlash\";\nimport { withLeadingSlash } from \"./withLeadingSlash\";\nimport { cleanPath } from \"./cleanPath\";\n\n/**\n * Converts a relative URL to an absolute URL using the current document base URI.\n * @param relativeUrl - The relative URL to convert\n * @returns The absolute URL\n * @since 1.0.0\n */\nexport function relativeURLToAbsolute(relativeUrl: string): string {\n return (\n withoutTrailingSlash(document.baseURI ?? window.location.origin) +\n cleanPath(withLeadingSlash(relativeUrl))\n );\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: string): string\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: undefined): undefined\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(url: null): null\n\n/**\n * Adds a trailing slash `/` to the given URL if it is not already present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * with a trailing slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string with a trailing slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withTrailingSlash\n *\n * @example\n * ```ts\n * withTrailingSlash('') // => '/'\n * withTrailingSlash('no/slash') // => 'no/slash/'\n * withTrailingSlash('already/has/slash/') // => 'already/has/slash/'\n * withTrailingSlash(undefined) // => undefined\n * withTrailingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withTrailingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[url.length - 1] === '/' ? url : url + '/'\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: string): string\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: undefined): undefined\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(url: null): null\n\n/**\n * Removes the leading slash `/` from the given URL if it is present.\n *\n * This function is useful for ensuring that URLs are properly formatted\n * without a leading slash, which is often required in web development for\n * consistency and to avoid issues with relative paths.\n *\n * @param url - The URL string to be processed. Can be `string`, `undefined`, or `null`.\n * @returns The URL string without a leading slash, or `undefined` if the input is `undefined`, or `null` if the input is `null`.\n *\n * @see https://radashi.js.org/reference/url/withoutLeadingSlash\n *\n * @example\n * ```ts\n * withoutLeadingSlash('') // => ''\n * withoutLeadingSlash('/') // => ''\n * withoutLeadingSlash('/no/slash') // => 'no/slash'\n * withoutLeadingSlash('already/has/slash') // => 'already/has/slash'\n * withoutLeadingSlash(undefined) // => undefined\n * withoutLeadingSlash(null) // => null\n * ```\n * @since 1.0.0\n */\nexport function withoutLeadingSlash(\n url: string | undefined | null,\n): string | undefined | null {\n if (url === undefined || url === null) {\n return url\n }\n return url[0] === '/' ? url.slice(1) : url\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,UACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,QAAQ,gBAAgB,KAAK;;;;ACP1C,SAAgB,eAAe,KAA2D;AACxF,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;CAIT,MAAM,aAAa,IAAI,QAAQ,IAAI;CACnC,MAAM,gBAAgB,IAAI,QAAQ,IAAI;CAEtC,IAAI,WAAW;AAEf,KAAI,eAAe,MAAM,kBAAkB,GAEzC,YAAW,KAAK,IAAI,YAAY,cAAc;UACrC,eAAe,GAExB,YAAW;UACF,kBAAkB,GAE3B,YAAW;AAIb,KAAI,aAAa,GACf,QAAO;AAIT,QAAO,IAAI,UAAU,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuDnC,SAAgB,SACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;CAET,MAAM,CAAC,QAAQ,IAAI,MAAM,OAAO;AAChC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPT,SAAgB,qBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,QAAQ,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;ACVhC,SAAgB,iBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,OAAO,MAAM,MAAM,MAAM;;;;;;;;;;;;;;;ACrFtC,SAAgB,sBAAsB,aAA6B;AAC/D,QACI,qBAAqB,SAAS,WAAW,OAAO,SAAS,OAAO,GAChE,UAAU,iBAAiB,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AC4EhD,SAAgB,kBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,IAAI,SAAS,OAAO,MAAM,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;ACFnD,SAAgB,oBACd,KAC2B;AAC3B,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAC/B,QAAO;AAET,QAAO,IAAI,OAAO,MAAM,IAAI,MAAM,EAAE,GAAG"}
|
package/llms.txt
CHANGED
package/meta/api.json
CHANGED