Skip to content

Commit

Permalink
chore: update automd syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Sep 6, 2024
1 parent cbb93c3 commit d225215
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const { normalizeURL, joinURL } = require("ufo");
import { parseURL } from "https://unpkg.com/ufo/dist/index.mjs";
```

<!-- AUTOMD_START generator="jsdocs" defaultGroup="utils" -->
<!-- automd:jsdocs src=./src -->

## Encoding Utils

Expand All @@ -58,7 +58,7 @@ Decodes query key (consistent with `encodeQueryKey` for plus encoding).

### `decodeQueryValue(text)`

Decode query value (consistent with encodeQueryValue for plus encoding).
Decode query value (consistent with `encodeQueryValue` for plus encoding).

### `encode(text)`

Expand Down Expand Up @@ -96,7 +96,7 @@ Takes a string of the form `username:password` and returns an object with the us

### `parseFilename(input)`

Parses a url and returns last segment in path as filename.
Parses a URL and returns last segment in path as filename.

If `{ strict: true }` is passed as the second argument, it will only return the last segment only if ending with an extension.

Expand Down Expand Up @@ -160,7 +160,7 @@ If the value is an array, it will be encoded as multiple key-value pairs with th

Parses and decodes a query string into an object.

input can be a query string with or without the leading `?`
The input can be a query string with or without the leading `?`.

### `stringifyQuery(query)`

Expand All @@ -183,7 +183,7 @@ cleanDoubleSlashes("http://example.com/analyze//http://localhost:3000//");

### `getQuery(input)`

Parses and decods the query object of an input URL into an object.
Parses and decodes the query object of an input URL into an object.

**Example:**

Expand All @@ -194,24 +194,22 @@ getQuery("http://foo.com/foo?test=123&unicode=%E5%A5%BD");

### `hasLeadingSlash(input)`

Checks if the input has a leading slash. (e.g. `/foo`)

### `hasProtocol(inputString, opts)`

Checks if the input has a leading slash (e.g. `/foo`).

### `hasTrailingSlash(input, respectQueryAndFragment?)`

Checks if the input has a trailing slash.

### `isEmptyURL(url)`

Checks if the input url is empty or `/`.
Checks if the input URL is empty or `/`.

### `isEqual(a, b, options)`

Checks if two paths are equal regardless of encoding, trailing slash, and leading slash differences.

You can make slash check strict by setting `{ trailingSlash: true, leadingSlash: true }` as options.

You can make encoding check strict by setting `{ encoding: true }` as options.

**Example:**
Expand All @@ -229,7 +227,7 @@ isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false

### `isNonEmptyURL(url)`

Checks if the input url is not empty nor `/`.
Checks if the input URL is not empty nor `/`.

### `isRelative(inputString)`

Expand Down Expand Up @@ -277,9 +275,9 @@ joinURL("a", "/b", "/c"); // "a/b/c"

### `normalizeURL(input)`

Normlizes inputed url:
Normlizes the input URL:

- Ensures url is properly encoded - Ensures pathname starts with slash - Preserves protocol/host if provided
- Ensures the URL is properly encoded - Ensures pathname starts with a slash - Preserves protocol/host if provided

**Example:**

Expand Down Expand Up @@ -310,7 +308,7 @@ If input aleady start with base, it will not be added again.

### `withFragment(input, hash)`

Add/Replace the fragment section of the URL.
Adds or replaces the fragment section of the URL.

**Example:**

Expand All @@ -322,7 +320,7 @@ withFragment("/foo#bar", ""); // "/foo"

### `withHttp(input)`

Adds or replaces url protocol to `http://`.
Adds or replaces the URL protocol to `http://`.

**Example:**

Expand All @@ -332,7 +330,7 @@ withHttp("https://example.com"); // http://example.com

### `withHttps(input)`

Adds or replaces url protocol to `https://`.
Adds or replaces the URL protocol to `https://`.

**Example:**

Expand Down Expand Up @@ -363,7 +361,7 @@ withoutFragment("http://example.com/foo?q=123#bar")

### `withoutHost(input)`

Removes the host from the URL preserving everything else.
Removes the host from the URL while preserving everything else.

**Example:**

Expand All @@ -376,21 +374,11 @@ withoutHost("http://example.com/foo?q=123#bar")

Removes leading slash from the URL or pathname.

### `withoutProtocol(input)`

Removes the protocol from the input.

**Example:**

```js
withoutProtocol("http://example.com"); // "example.com"
```

### `withoutTrailingSlash(input, respectQueryAndFragment?)`

Removes trailing slash from the URL or pathname.

If second argument is true, it will only remove the trailing slash if it's not part of the query or fragment with cost of more expensive operations.
If second argument is `true`, it will only remove the trailing slash if it's not part of the query or fragment with cost of more expensive operations.

**Example:**

Expand All @@ -402,7 +390,7 @@ withoutTrailingSlash("/path/?query=true", true); // "/path?query=true"

### `withProtocol(input, protocol)`

Adds or Replaces protocol of the input URL.
Adds or replaces protocol of the input URL.

**Example:**

Expand All @@ -422,7 +410,7 @@ withQuery("/foo?page=a", { token: "secret" }); // "/foo?page=a&token=secret"

### `withTrailingSlash(input, respectQueryAndFragment?)`

Ensures url ends with a trailing slash.
Ensures the URL ends with a trailing slash.

If seccond argument is `true`, it will only add the trailing slash if it's not part of the query or fragment with cost of more expensive operation.

Expand All @@ -434,8 +422,21 @@ withTrailingSlash("/foo"); // "/foo/"
withTrailingSlash("/path?query=true", true); // "/path/?query=true"
```

### `$URL()`

### `hasProtocol(inputString, opts)`

### `withoutProtocol(input)`

Removes the protocol from the input.

**Example:**

```js
withoutProtocol("http://example.com"); // "example.com"
```

<!-- AUTOMD_END -->
<!-- /automd -->

## License

Expand Down

0 comments on commit d225215

Please sign in to comment.