@nauverse/make-url
Advanced tools
Comparing version 1.10.3 to 1.10.4
@@ -1,2 +0,66 @@ | ||
export * from './makeURL'; | ||
export { default as makeURL } from './makeURL'; | ||
export declare const BASE_DEFAULT_MAKE_URL_CONFIG: IConfig; | ||
/** | ||
* Returns the default configuration for the `makeURL` function. | ||
* @returns The default configuration object. | ||
*/ | ||
export declare function getMakeURLDefaultConfig(): IConfig; | ||
declare interface IConfig { | ||
forceProtocol: TForceProtocol; | ||
trailingSlash: TTrailingSlash; | ||
strict: boolean; | ||
allowEmptyPathSegments: boolean; | ||
arraySerializer: TArraySerializer; | ||
} | ||
declare interface IParams<T> { | ||
params: Record<string, unknown>; | ||
hash: string; | ||
config: T; | ||
} | ||
/** | ||
* Generates a URL based on the provided parameters and fragments. | ||
* | ||
* @param firstArg - The first argument can be a partial IParams object or a string. If it's a string, it will be used as the first fragment. | ||
* @param fragments - The rest of the fragments to be used in the URL. | ||
* @returns The generated URL. | ||
* @throws If the first argument is not a string or if the params object is not the last argument. | ||
* @throws If the generated URL is not a valid complete URL (meaning it contains a domain, something like https://example.com/ajajaja) and the strict mode is enabled. | ||
* @example | ||
* makeURL("example.com", "path", "to", "file") // "https://example.com/path/to/file" | ||
* makeURL({ | ||
* queryParams: { | ||
* key: "value" | ||
* } | ||
* }, "example.com", "path", "to", "file") // "https://example.com/path/to/file?key=value" | ||
* makeURL({ | ||
* queryParams: { | ||
* key: "value", | ||
* otherKey: 123 | ||
* } | ||
* }, "example.com", "path", "to/file/:otherKey") // "https://example.com/path/to/file/123?key=value" | ||
*/ | ||
export declare function makeURL(...args: Array<string | Partial<IParams<Partial<IConfig>>>>): string; | ||
/** | ||
* Sets the makeURL default config params. This function is used to set the default config params for the makeURL function so you don't have to pass them every time you use it. | ||
* | ||
* @param config - The partial IConfig object containing the default config parameters to be set. | ||
* @example | ||
* setMakeURLParams({ | ||
* forceProtocol: "http", | ||
* trailingSlash: "add", | ||
* strict: false | ||
* }) | ||
*/ | ||
export declare function setMakeURLDefaultConfig(config: Partial<IConfig>): void; | ||
declare type TArraySerializer = "stringify" | "repeat" | "comma"; | ||
declare type TForceProtocol = "http" | "https" | "none" | "auto" | "auto-insecure"; | ||
declare type TTrailingSlash = "add" | "remove"; | ||
export { } |
@@ -72,3 +72,3 @@ function g(a) { | ||
n !== "" && (f.push(n), n = ""), f.push(h); | ||
}), n !== "" && (f.push(n), n = ""), r && (f = [a[0], ...f]), f; | ||
}), n !== "" && (f.push(n), n = ""), r && a[0] && (f = [a[0], ...f]), f; | ||
} | ||
@@ -91,3 +91,3 @@ function L(a, r) { | ||
c | ||
), n.length > 1 && (n[1] = n[1].replace(/^\/*/, "")); | ||
), n.length > 1 && (n[1] = (n[1] ?? "").replace(/^\/*/, "")); | ||
} | ||
@@ -217,1 +217,2 @@ return n = U(n, e), { | ||
}; | ||
//# sourceMappingURL=make-url.js.map |
@@ -29,3 +29,3 @@ { | ||
], | ||
"version": "1.10.3", | ||
"version": "1.10.4", | ||
"type": "module", | ||
@@ -54,8 +54,8 @@ "main": "./dist/make-url.umd.cjs", | ||
"scripts": { | ||
"build": "rimraf dist tsc && vite build", | ||
"build": "tsc && vite build", | ||
"test": "vitest", | ||
"test:run": "vitest run", | ||
"coverage": "vitest run --coverage", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "eslint --fix . --ext .ts", | ||
"test:coverage": "vitest run --coverage", | ||
"lint": "eslint . --ext .ts --report-unused-disable-directives --max-warnings 0", | ||
"lint:fix": "eslint --fix . --ext .ts --report-unused-disable-directives --max-warnings 0", | ||
"prepare": "husky" | ||
@@ -76,3 +76,2 @@ }, | ||
"prettier": "3.2.5", | ||
"rimraf": "5.0.5", | ||
"typescript": "5.4.4", | ||
@@ -82,3 +81,4 @@ "vite": "5.2.8", | ||
"vitest": "1.4.0" | ||
} | ||
}, | ||
"peerDependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
119730
16
8
291