Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { rm } from "node:fs/promises";
import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
hooks: {
async "build:done"() {
await rm("dist/index.d.ts");
},
},
});
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"./*": "./*"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"types": "./dist/index.d.mts",
"files": [
"dist"
],
Expand Down
18 changes: 9 additions & 9 deletions src/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export function encodeHash(text: string): string {
.replace(ENC_CARET_RE, "^");
}

/**
* Encodes hostname with punycode encoding.
*
* @group encoding_utils
*/
export function encodeHost(name = "") {
return toASCII(name);
}

/**
* Encodes characters that need to be encoded for query values in the query
* section of the URL.
Expand Down Expand Up @@ -165,12 +174,3 @@ export function decodeQueryKey(text: string): string {
export function decodeQueryValue(text: string): string {
return decode(text.replace(PLUS_RE, " "));
}

/**
* Encodes hostname with punycode encoding.
*
* @group encoding_utils
*/
export function encodeHost(name = "") {
return toASCII(name);
}
70 changes: 65 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
export * from "./encoding";
export * from "./parse";
export * from "./query";
export * from "./url";
export * from "./utils";
export {
encode,
encodeHash,
encodeHost,
encodeQueryValue,
encodeQueryKey,
encodePath,
encodeParam,
decode,
decodePath,
decodeQueryKey,
decodeQueryValue,
} from "./encoding";

export type { ParsedURL, ParsedAuth, ParsedHost } from "./parse";

export {
parseURL,
parsePath,
parseAuth,
parseHost,
stringifyParsedURL,
parseFilename,
} from "./parse";

export type { QueryValue, QueryObject, ParsedQuery } from "./query";

export { parseQuery, encodeQueryItem, stringifyQuery } from "./query";

export { $URL, createURL } from "./url";

export type { HasProtocolOptions } from "./utils";

export {
isRelative,
hasProtocol,
isScriptProtocol,
hasTrailingSlash,
withoutTrailingSlash,
withTrailingSlash,
hasLeadingSlash,
withoutLeadingSlash,
withLeadingSlash,
cleanDoubleSlashes,
withBase,
withoutBase,
withQuery,
filterQuery,
getQuery,
isEmptyURL,
isNonEmptyURL,
joinURL,
joinRelativeURL,
withHttp,
withHttps,
withoutProtocol,
withProtocol,
normalizeURL,
resolveURL,
isSamePath,
isEqual,
withFragment,
withoutFragment,
withoutHost,
} from "./utils";
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true
"esModuleInterop": true,
"strict": true,
},
"include": [
"src"
]
"include": ["src"]
}