Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 6, 2024
1 parent 8a78b87 commit 5ab6d16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)`
Expand Down Expand Up @@ -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)`
Expand All @@ -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)`
Expand Down Expand Up @@ -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.
Expand All @@ -413,6 +415,7 @@ Removes the protocol from the input.
withoutProtocol("http://example.com"); // "example.com"
```


<!-- AUTOMD_END -->

## License
Expand Down
15 changes: 9 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ab6d16

Please sign in to comment.