@tinyhttp/url
Advanced tools
Comparing version 1.1.2 to 1.1.4
@@ -7,6 +7,7 @@ import { ParsedUrlQuery } from 'querystring'; | ||
export declare const getURLParams: ({ pattern, keys }: Regex, reqUrl?: string) => URLParams; | ||
export declare const getQueryParams: (url?: string) => ParsedUrlQuery; | ||
export declare type URLParams = { | ||
[key: string]: string; | ||
}; | ||
export declare const getPathname: (u: string) => string; | ||
export declare const getQueryParams: (url?: string) => ParsedUrlQuery; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { parse } from 'url'; | ||
import { parse } from 'querystring'; | ||
@@ -6,10 +6,13 @@ const getURLParams = ({ pattern, keys }, reqUrl = '/') => { | ||
const params = {}; | ||
if (matches) { | ||
if (matches) | ||
for (let i = 0; i < keys.length; i++) | ||
params[keys[i]] = matches[i + 1]; | ||
} | ||
return params; | ||
}; | ||
const getQueryParams = (url = '/') => parse(url, true).query; | ||
const getPathname = (u) => { | ||
const end = u.indexOf('?'); | ||
return u.slice(0, end === -1 ? u.length : end); | ||
}; | ||
const getQueryParams = (url = '/') => parse(url.slice(url.indexOf('?') + 1)); | ||
export { getQueryParams, getURLParams }; | ||
export { getPathname, getQueryParams, getURLParams }; |
{ | ||
"name": "@tinyhttp/url", | ||
"version": "1.1.2", | ||
"version": "1.1.4", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "URL extensions for tinyhttp", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4158
46