From 3301e51f21789e18e60fa28c49d0649f17b95730 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 6 Feb 2024 19:14:23 +0100 Subject: [PATCH] chore: update automd --- README.md | 46 ++++++++++++++++++++++------------------------ package.json | 4 ++-- pnpm-lock.yaml | 15 ++++++++++----- src/encoding.ts | 22 +++++++++++----------- src/parse.ts | 12 ++++++------ src/query.ts | 6 +++--- 6 files changed, 54 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index f2a6c99..2040ebf 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,9 @@ const { normalizeURL, joinURL } = require("ufo"); import { parseURL } from "https://unpkg.com/ufo/dist/index.mjs"; ``` -# Utils + - - -## Encoding +## Encoding Utils ### `decode(text)` @@ -90,7 +88,7 @@ Encode characters that need to be encoded query values on the query section of t Encode characters that need to be encoded query values on the query section of the URL. -## Parsing +## Parsing Utils ### `parseAuth(input)` @@ -120,7 +118,7 @@ Takes a string, and returns an object with two properties: `hostname` and `port` Splits the input string into three parts, and returns an object with those three parts. -### `parseURL(input, defaultProto)` +### `parseURL(input, defaultProto?)` Takes a URL string and returns an object with the URL's `protocol`, `auth`, `host`, `pathname`, `search`, and `hash`. @@ -150,7 +148,7 @@ obj.host = "bar.com"; stringifyParsedURL(obj); // "http://bar.com/foo?test=123#token" ``` -## Qeury +## Qeury Utils ### `encodeQueryItem(key, value)` @@ -198,7 +196,10 @@ getQuery("http://foo.com/foo?test=123&unicode=%E5%A5%BD"); Checks if the input has a leading slash. (e.g. `/foo`) -### `hasTrailingSlash(input, respectQueryAndFragment)` +### `hasProtocol(inputString, opts)` + + +### `hasTrailingSlash(input, respectQueryAndFragment?)` Checks if the input has a trailing slash. @@ -250,7 +251,7 @@ Check two paths are equal or not. Trailing slash and encoding are normalized bef isSamePath("/foo", "/foo/"); // true ``` -### `isScriptProtocol(protocol)` +### `isScriptProtocol(protocol?)` Checks if the input protocol is any of the dangerous `blob:`, `data:`, `javascript`: or `vbscript:` protocols. @@ -354,7 +355,17 @@ withoutFragment("http://example.com/foo?q=123#bar") Removes leading slash from the URL or pathname. -### `withoutTrailingSlash(input, respectQueryAndFragment)` +### `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. @@ -388,7 +399,7 @@ Add/Replace the query section of the URL. withQuery("/foo?page=a", { token: "secret" }); // "/foo?page=a&token=secret" ``` -### `withTrailingSlash(input, respectQueryAndFragment)` +### `withTrailingSlash(input, respectQueryAndFragment?)` Ensures url ends with a trailing slash. @@ -402,19 +413,6 @@ withTrailingSlash("/foo"); // "/foo/" withTrailingSlash("/path?query=true", true); // "/path/?query=true" ``` -### `hasProtocol(inputString, opts)` - - -### `withoutProtocol(input)` - -Removes the protocol from the input. - -**Example:** - -```js -withoutProtocol("http://example.com"); // "example.com" -``` - diff --git a/package.json b/package.json index 1d66c32..21a5133 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "devDependencies": { "@types/node": "^20.11.16", "@vitest/coverage-v8": "^1.2.2", - "automd": "^0.1.1", + "automd": "^0.1.4", "changelogen": "^0.5.5", "eslint": "^8.56.0", "eslint-config-unjs": "^0.2.1", @@ -44,4 +44,4 @@ "vitest": "^1.2.2" }, "packageManager": "pnpm@8.15.1" -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2cce6fa..bcb97ab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ devDependencies: specifier: ^1.2.2 version: 1.2.2(vitest@1.2.2) automd: - specifier: ^0.1.1 - version: 0.1.1 + specifier: ^0.1.4 + version: 0.1.4 changelogen: specifier: ^0.5.5 version: 0.5.5 @@ -1168,14 +1168,15 @@ packages: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} dev: true - /automd@0.1.1: - resolution: {integrity: sha512-t5qeYos5yd46/b7QO9P8eq21IIP0WWTivXIb4yIXMu1o31UZ3QEAJHrciGKa9I2Q27SMfZBRMIHFneiE0e6THw==} + /automd@0.1.4: + resolution: {integrity: sha512-zRo8YtH2SI1fa4gJn/ykVuunfO/SAE5+I4XTEu6dQkUFOV6ydYhMI1F818LgX5K2CoBQJNNWKiF67CNz3ixTfg==} hasBin: true dependencies: citty: 0.1.5 consola: 3.2.3 + destr: 2.0.2 magic-string: 0.30.7 - scule: 1.2.0 + scule: 1.3.0 untyped: 1.4.2 transitivePeerDependencies: - supports-color @@ -4071,6 +4072,10 @@ packages: resolution: {integrity: sha512-CRCmi5zHQnSoeCik9565PONMg0kfkvYmcSqrbOJY4txFfy1wvVULV4FDaiXhUblUgahdqz3F2NwHZ8i4eBTwUw==} dev: true + /scule@1.3.0: + resolution: {integrity: sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==} + dev: true + /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true diff --git a/src/encoding.ts b/src/encoding.ts index 33b0baf..d3f1bb9 100644 --- a/src/encoding.ts +++ b/src/encoding.ts @@ -23,7 +23,7 @@ const ENC_ENC_SLASH_RE = /%252f/gi; * Encode characters that need to be encoded on the path, search and hash * sections of the URL. * - * @group encoding + * @group encoding_utils * * @param text - string to encode * @returns encoded string @@ -35,7 +35,7 @@ export function encode(text: string | number): string { /** * Encode characters that need to be encoded on the hash section of the URL. * - * @group encoding + * @group encoding_utils * * @param text - string to encode * @returns encoded string @@ -51,7 +51,7 @@ export function encodeHash(text: string): string { * Encode characters that need to be encoded query values on the query * section of the URL. * - * @group encoding + * @group encoding_utils * * @param input - string to encode * @returns encoded string @@ -74,7 +74,7 @@ export function encodeQueryValue(input: QueryValue): string { * Encode characters that need to be encoded query values on the query * section of the URL and also encodes the `=` character. * - * @group encoding + * @group encoding_utils * * @param text - string to encode */ @@ -85,7 +85,7 @@ export function encodeQueryKey(text: string | number): string { /** * Encode characters that need to be encoded on the path section of the URL. * - * @group encoding + * @group encoding_utils * * @param text - string to encode * @returns encoded string @@ -104,7 +104,7 @@ export function encodePath(text: string | number): string { * param. This function encodes everything `encodePath` does plus the * slash (`/`) character. * - * @group encoding + * @group encoding_utils * * @param text - string to encode * @returns encoded string @@ -117,7 +117,7 @@ export function encodeParam(text: string | number): string { * Decode text using `decodeURIComponent`. Returns the original text if it * fails. * - * @group encoding + * @group encoding_utils * * @param text - string to decode * @returns decoded string @@ -133,7 +133,7 @@ export function decode(text: string | number = ""): string { /** * Decode path section of URL (consistent with encodePath for slash encoding). * - * @group encoding + * @group encoding_utils * * @param text - string to decode * @returns decoded string @@ -145,7 +145,7 @@ export function decodePath(text: string): string { /** * Decodes query key (consistent with `encodeQueryKey` for plus encoding). * - * @group encoding + * @group encoding_utils * * @param text - string to decode * @returns decoded string @@ -157,7 +157,7 @@ export function decodeQueryKey(text: string): string { /** * Decode query value (consistent with encodeQueryValue for plus encoding). * - * @group encoding + * @group encoding_utils * * @param text - string to decode * @returns decoded string @@ -169,7 +169,7 @@ export function decodeQueryValue(text: string): string { /** * Encodes hostname with punycode encoding. * - * @group encoding + * @group encoding_utils */ export function encodeHost(name = "") { return toASCII(name); diff --git a/src/parse.ts b/src/parse.ts index c7f388e..37d5808 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -38,7 +38,7 @@ export interface ParsedHost { * // { protocol: 'https:', auth: '', host: 'foo.com', pathname: '/foo', search: '?test=123', hash: '#token' } * ``` * - * @group parsing + * @group parsing_utils * * @param [input] - The URL to parse. * @param [defaultProto] - The default protocol to use if the input doesn't have one. @@ -88,7 +88,7 @@ export function parseURL(input = "", defaultProto?: string): ParsedURL { /** * Splits the input string into three parts, and returns an object with those three parts. * - * @group parsing + * @group parsing_utils * * @param [input] - The URL to parse. * @returns An object with three properties: `pathname`, `search`, and `hash`. @@ -109,7 +109,7 @@ export function parsePath(input = ""): ParsedURL { * Takes a string of the form `username:password` and returns an object with the username and * password decoded. * - * @group parsing + * @group parsing_utils * * @param [input] - The URL to parse. * @returns An object with two properties: username and password. @@ -125,7 +125,7 @@ export function parseAuth(input = ""): ParsedAuth { /** * Takes a string, and returns an object with two properties: `hostname` and `port`. * - * @group parsing + * @group parsing_utils * * @param [input] - The URL to parse. * @returns A function that takes a string and returns an object with two properties: `hostname` and @@ -142,7 +142,7 @@ export function parseHost(input = ""): ParsedHost { /** * Takes a `ParsedURL` object and returns the stringified URL. * - * @group parsing + * @group parsing_utils * * @example * @@ -179,7 +179,7 @@ const FILENAME_REGEX = /\/([^/]+)$/; * * If `{ strict: true }` is passed as the second argument, it will only return the last segment only if ending with an extension. * - * @group parsing + * @group parsing_utils * * @example * diff --git a/src/query.ts b/src/query.ts index 089385d..5645264 100644 --- a/src/query.ts +++ b/src/query.ts @@ -26,7 +26,7 @@ export type ParsedQuery = Record; * @note * The `__proto__` and `constructor` keys are ignored to prevent prototype pollution. * - * @group qeury + * @group qeury_utils */ export function parseQuery( parametersString = "" @@ -61,7 +61,7 @@ export function parseQuery( * * If the value is an array, it will be encoded as multiple key-value pairs with the same key. * - * @group qeury + * @group qeury_utils */ export function encodeQueryItem( key: string, @@ -86,7 +86,7 @@ export function encodeQueryItem( /** * Stringfies and encodes a query object into a query string. * - * @group qeury + * @group qeury_utils */ export function stringifyQuery(query: QueryObject): string { return Object.keys(query)