From 5ab6d166ea9f83edda86d72b19144aae2aa1af5e Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 6 Feb 2024 01:11:00 +0100 Subject: [PATCH] chore: update docs --- README.md | 19 +++++++++++-------- src/utils.ts | 15 +++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c39b559..f2a6c99 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,6 @@ isEqual("foo/", "foo"); // true isEqual("/foo bar", "/foo%20bar"); // true // Strict compare - isEqual("/foo", "foo", { leadingSlash: true }); // false isEqual("foo/", "foo", { trailingSlash: true }); // false isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false @@ -274,8 +273,11 @@ Normlizes inputed url: **Example:** ```js -normalizeURL("test?query=123 123#hash, test"); // "test?query=123%20123#hash,%20test" -normalizeURL("http://localhost:3000"); // "http://localhost:3000" +normalizeURL("test?query=123 123#hash, test"); +// Returns "test?query=123%20123#hash,%20test" + +normalizeURL("http://localhost:3000"); +// Returns "http://localhost:3000" ``` ### `resolveURL(base)` @@ -344,7 +346,8 @@ Removes the fragment section from the URL. **Example:** ```js -withoutFragment("http://example.com/foo?q=123#bar"); // "http://example.com/foo?q=123" +withoutFragment("http://example.com/foo?q=123#bar") +// Returns "http://example.com/foo?q=123" ``` ### `withoutLeadingSlash(input)` @@ -362,8 +365,7 @@ If second argument is is true, it will only remove the trailing slash if it's no ```js withoutTrailingSlash("/foo/"); // "/foo" -withoutTrailingSlash("/path/?query=true", true); -("/path?query=true"); +withoutTrailingSlash("/path/?query=true", true); // "/path?query=true" ``` ### `withProtocol(input, protocol)` @@ -397,12 +399,12 @@ If seccond argument is `true`, it will only add the trailing slash if it's not p ```js withTrailingSlash("/foo"); // "/foo/" -withTrailingSlash("/path?query=true", true); -("/path/?query=true"); +withTrailingSlash("/path?query=true", true); // "/path/?query=true" ``` ### `hasProtocol(inputString, opts)` + ### `withoutProtocol(input)` Removes the protocol from the input. @@ -413,6 +415,7 @@ Removes the protocol from the input. withoutProtocol("http://example.com"); // "example.com" ``` + ## License diff --git a/src/utils.ts b/src/utils.ts index 9bcfece..0bbe92d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -100,7 +100,7 @@ export function hasTrailingSlash( * ```js * withoutTrailingSlash("/foo/"); // "/foo" * - * withoutTrailingSlash("/path/?query=true", true); "/path?query=true" + * withoutTrailingSlash("/path/?query=true", true); // "/path?query=true" * ``` * * @group utils @@ -140,7 +140,7 @@ export function withoutTrailingSlash( * ```js * withTrailingSlash("/foo"); // "/foo/" * - * withTrailingSlash("/path?query=true", true); "/path/?query=true" + * withTrailingSlash("/path?query=true", true); // "/path/?query=true" * ``` * * @group utils @@ -404,8 +404,11 @@ export function withProtocol(input: string, protocol: string): string { * @example * * ```js - * normalizeURL("test?query=123 123#hash, test"); // "test?query=123%20123#hash,%20test" - * normalizeURL("http://localhost:3000"); // "http://localhost:3000" + * normalizeURL("test?query=123 123#hash, test"); + * // Returns "test?query=123%20123#hash,%20test" + * + * normalizeURL("http://localhost:3000"); + * // Returns "http://localhost:3000" * ``` * * @group utils @@ -513,7 +516,6 @@ interface CompareURLOptions { * isEqual("/foo bar", "/foo%20bar"); // true * * // Strict compare - * * isEqual("/foo", "foo", { leadingSlash: true }); // false * isEqual("foo/", "foo", { trailingSlash: true }); // false * isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false @@ -565,7 +567,8 @@ export function withFragment(input: string, hash: string): string { * @example * * ```js - * withoutFragment("http://example.com/foo?q=123#bar") // "http://example.com/foo?q=123" + * withoutFragment("http://example.com/foo?q=123#bar") + * // Returns "http://example.com/foo?q=123" * ``` * * @group utils