Skip to content

Commit 5ab6d16

Browse files
committed
chore: update docs
1 parent 8a78b87 commit 5ab6d16

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ isEqual("foo/", "foo"); // true
221221
isEqual("/foo bar", "/foo%20bar"); // true
222222

223223
// Strict compare
224-
225224
isEqual("/foo", "foo", { leadingSlash: true }); // false
226225
isEqual("foo/", "foo", { trailingSlash: true }); // false
227226
isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false
@@ -274,8 +273,11 @@ Normlizes inputed url:
274273
**Example:**
275274

276275
```js
277-
normalizeURL("test?query=123 123#hash, test"); // "test?query=123%20123#hash,%20test"
278-
normalizeURL("http://localhost:3000"); // "http://localhost:3000"
276+
normalizeURL("test?query=123 123#hash, test");
277+
// Returns "test?query=123%20123#hash,%20test"
278+
279+
normalizeURL("http://localhost:3000");
280+
// Returns "http://localhost:3000"
279281
```
280282

281283
### `resolveURL(base)`
@@ -344,7 +346,8 @@ Removes the fragment section from the URL.
344346
**Example:**
345347

346348
```js
347-
withoutFragment("http://example.com/foo?q=123#bar"); // "http://example.com/foo?q=123"
349+
withoutFragment("http://example.com/foo?q=123#bar")
350+
// Returns "http://example.com/foo?q=123"
348351
```
349352

350353
### `withoutLeadingSlash(input)`
@@ -362,8 +365,7 @@ If second argument is is true, it will only remove the trailing slash if it's no
362365
```js
363366
withoutTrailingSlash("/foo/"); // "/foo"
364367

365-
withoutTrailingSlash("/path/?query=true", true);
366-
("/path?query=true");
368+
withoutTrailingSlash("/path/?query=true", true); // "/path?query=true"
367369
```
368370

369371
### `withProtocol(input, protocol)`
@@ -397,12 +399,12 @@ If seccond argument is `true`, it will only add the trailing slash if it's not p
397399
```js
398400
withTrailingSlash("/foo"); // "/foo/"
399401

400-
withTrailingSlash("/path?query=true", true);
401-
("/path/?query=true");
402+
withTrailingSlash("/path?query=true", true); // "/path/?query=true"
402403
```
403404

404405
### `hasProtocol(inputString, opts)`
405406

407+
406408
### `withoutProtocol(input)`
407409

408410
Removes the protocol from the input.
@@ -413,6 +415,7 @@ Removes the protocol from the input.
413415
withoutProtocol("http://example.com"); // "example.com"
414416
```
415417

418+
416419
<!-- AUTOMD_END -->
417420

418421
## License

src/utils.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function hasTrailingSlash(
100100
* ```js
101101
* withoutTrailingSlash("/foo/"); // "/foo"
102102
*
103-
* withoutTrailingSlash("/path/?query=true", true); "/path?query=true"
103+
* withoutTrailingSlash("/path/?query=true", true); // "/path?query=true"
104104
* ```
105105
*
106106
* @group utils
@@ -140,7 +140,7 @@ export function withoutTrailingSlash(
140140
* ```js
141141
* withTrailingSlash("/foo"); // "/foo/"
142142
*
143-
* withTrailingSlash("/path?query=true", true); "/path/?query=true"
143+
* withTrailingSlash("/path?query=true", true); // "/path/?query=true"
144144
* ```
145145
*
146146
* @group utils
@@ -404,8 +404,11 @@ export function withProtocol(input: string, protocol: string): string {
404404
* @example
405405
*
406406
* ```js
407-
* normalizeURL("test?query=123 123#hash, test"); // "test?query=123%20123#hash,%20test"
408-
* normalizeURL("http://localhost:3000"); // "http://localhost:3000"
407+
* normalizeURL("test?query=123 123#hash, test");
408+
* // Returns "test?query=123%20123#hash,%20test"
409+
*
410+
* normalizeURL("http://localhost:3000");
411+
* // Returns "http://localhost:3000"
409412
* ```
410413
*
411414
* @group utils
@@ -513,7 +516,6 @@ interface CompareURLOptions {
513516
* isEqual("/foo bar", "/foo%20bar"); // true
514517
*
515518
* // Strict compare
516-
*
517519
* isEqual("/foo", "foo", { leadingSlash: true }); // false
518520
* isEqual("foo/", "foo", { trailingSlash: true }); // false
519521
* isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false
@@ -565,7 +567,8 @@ export function withFragment(input: string, hash: string): string {
565567
* @example
566568
*
567569
* ```js
568-
* withoutFragment("http://example.com/foo?q=123#bar") // "http://example.com/foo?q=123"
570+
* withoutFragment("http://example.com/foo?q=123#bar")
571+
* // Returns "http://example.com/foo?q=123"
569572
* ```
570573
*
571574
* @group utils

0 commit comments

Comments
 (0)