@tinyhttp/url
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -1,21 +0,23 @@ | ||
import { parse } from 'querystring'; | ||
const getURLParams = ({ pattern, keys }, reqUrl = '/') => { | ||
const matches = pattern.exec(reqUrl); | ||
const params = {}; | ||
if (matches && typeof keys !== 'boolean') | ||
for (let i = 0; i < keys.length; i++) { | ||
if (matches[i + 1]) { | ||
params[keys[i]] = decodeURIComponent(matches[i + 1]); | ||
} | ||
} | ||
return params; | ||
import { parse } from "querystring"; | ||
const getURLParams = ({ pattern, keys }, reqUrl = "/") => { | ||
const matches = pattern.exec(reqUrl); | ||
const params = {}; | ||
if (matches && typeof keys !== "boolean") | ||
for (let i = 0; i < keys.length; i++) { | ||
if (matches[i + 1]) { | ||
params[keys[i]] = decodeURIComponent(matches[i + 1]); | ||
} | ||
} | ||
return params; | ||
}; | ||
const getQueryIndex = (url) => { | ||
const index = url.indexOf('?'); | ||
return index === -1 ? url.length : index; | ||
const index = url.indexOf("?"); | ||
return index === -1 ? url.length : index; | ||
}; | ||
const getPathname = (url) => url.slice(0, getQueryIndex(url)); | ||
const getQueryParams = (url = '/') => parse(url.slice(getQueryIndex(url) + 1)); | ||
export { getPathname, getQueryParams, getURLParams }; | ||
const getQueryParams = (url = "/") => parse(url.slice(getQueryIndex(url) + 1)); | ||
export { | ||
getPathname, | ||
getQueryParams, | ||
getURLParams | ||
}; |
{ | ||
"name": "@tinyhttp/url", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"type": "module", | ||
@@ -31,5 +31,8 @@ "description": "URL extensions for tinyhttp", | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"scripts": { | ||
"build": "rollup -c ./rollup.config.js" | ||
"dev": "vite", | ||
"build": "vite build", | ||
"postbuild": "tsc --emitDeclarationOnly" | ||
} | ||
} |
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
3581
6
38