-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to filter query params by filter function
- Loading branch information
Showing
5 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { urlNormalize } from "./src/main" | ||
|
||
// node --loader tsm --no-warnings bench.ts | ||
|
||
const bench = (name: string, count: number, fn: () => void) => { | ||
const st = Date.now() | ||
for (let i = 0; i < count; ++i) fn() | ||
const dt = Date.now() - st | ||
console.log(`${name} x ${count} = ${dt / 1000}s (${dt / count}ms per it)`) | ||
} | ||
|
||
const main = () => { | ||
bench("urlNormalize – simple", 1e5, () => { | ||
urlNormalize("https://www.google.com") | ||
}) | ||
|
||
bench("urlNormalize – harder", 1e5, () => { | ||
urlNormalize("://www.example.com/foo//bar/../baz?b=2&a=1#tag") | ||
}) | ||
|
||
bench("urlNormalize – replace protocol", 1e5, () => { | ||
urlNormalize("www.example.com/foo//bar/../baz?b=2&a=1#tag", { forceProtocol: "sftp" }) | ||
}) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
{ | ||
"type": "module", | ||
"name": "url-normalize", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Vlad Pronsky <[email protected]>", | ||
"repository": "vladkens/url-normalize", | ||
"description": "Normalize URLs to a standardized form by removing unnecessary characters, decoding encoded characters, removing default index pages, removing trailing slashes, and more.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"url", | ||
"normalize", | ||
"canonical", | ||
"domain", | ||
"extract", | ||
"humanize", | ||
"normalization", | ||
"normalize", | ||
"punycode", | ||
"querystrings", | ||
"unicode", | ||
"uri", | ||
"url-normalization", | ||
"url-normalize", | ||
"querystrings", | ||
"domain", | ||
"extract", | ||
"canonical" | ||
"url" | ||
], | ||
"files": [ | ||
"dist" | ||
|
@@ -26,6 +29,7 @@ | |
"test": "uvu -r tsm tests/", | ||
"test-cov": "c8 --include=src yarn test", | ||
"test-watch": "watchexec -e ts 'clear && yarn test'", | ||
"bench": "node --loader tsm --no-warnings benchmark.ts", | ||
"format": "prettier --write '{src,tests}/**/*.{js,jsx,ts,tsx}'", | ||
"format-check": "prettier --check '{src,tests}/**/*.{js,jsx,ts,tsx}'" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters