Skip to content

Commit 666091d

Browse files
committedMay 3, 2024·
style: lint with prettier defaults
1 parent 0c67673 commit 666091d

10 files changed

+24
-26
lines changed
 

‎.prettierrc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
{
2-
"trailingComma": "es5"
3-
}
1+
{}

‎src/parse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface ParsedHost {
4646
*/
4747
export function parseURL(input = "", defaultProto?: string): ParsedURL {
4848
const _specialProtoMatch = input.match(
49-
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
49+
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i,
5050
);
5151
if (_specialProtoMatch) {
5252
const [, _proto, _pathname = ""] = _specialProtoMatch;
@@ -71,7 +71,7 @@ export function parseURL(input = "", defaultProto?: string): ParsedURL {
7171
.match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
7272
const [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
7373
const { pathname, search, hash } = parsePath(
74-
path.replace(/\/(?=[A-Za-z]:)/, "")
74+
path.replace(/\/(?=[A-Za-z]:)/, ""),
7575
);
7676

7777
return {

‎src/query.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type ParsedQuery = Record<string, string | string[]>;
2929
* @group Query_utils
3030
*/
3131
export function parseQuery<T extends ParsedQuery = ParsedQuery>(
32-
parametersString = ""
32+
parametersString = "",
3333
): T {
3434
const object: ParsedQuery = {};
3535
if (parametersString[0] === "?") {
@@ -65,7 +65,7 @@ export function parseQuery<T extends ParsedQuery = ParsedQuery>(
6565
*/
6666
export function encodeQueryItem(
6767
key: string,
68-
value: QueryValue | QueryValue[]
68+
value: QueryValue | QueryValue[],
6969
): string {
7070
if (typeof value === "number" || typeof value === "boolean") {
7171
value = String(value);

‎src/url.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class $URL implements URL {
2323
constructor(input = "") {
2424
if (typeof input !== "string") {
2525
throw new TypeError(
26-
`URL input should be string received ${typeof input} (${input})`
26+
`URL input should be string received ${typeof input} (${input})`,
2727
);
2828
}
2929

@@ -77,7 +77,7 @@ export class $URL implements URL {
7777
} else {
7878
p.append(
7979
name,
80-
typeof value === "string" ? value : JSON.stringify(value)
80+
typeof value === "string" ? value : JSON.stringify(value),
8181
);
8282
}
8383
}

‎src/utils.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ export interface HasProtocolOptions {
4343
*/
4444
export function hasProtocol(
4545
inputString: string,
46-
opts?: HasProtocolOptions
46+
opts?: HasProtocolOptions,
4747
): boolean;
4848
/** @deprecated Same as { hasProtocol(inputString, { acceptRelative: true }) */
4949
export function hasProtocol(
5050
inputString: string,
51-
acceptRelative: boolean
51+
acceptRelative: boolean,
5252
): boolean;
5353
export function hasProtocol(
5454
inputString: string,
55-
opts: boolean | HasProtocolOptions = {}
55+
opts: boolean | HasProtocolOptions = {},
5656
): boolean {
5757
if (typeof opts === "boolean") {
5858
opts = { acceptRelative: opts };
@@ -82,7 +82,7 @@ export function isScriptProtocol(protocol?: string) {
8282
*/
8383
export function hasTrailingSlash(
8484
input = "",
85-
respectQueryAndFragment?: boolean
85+
respectQueryAndFragment?: boolean,
8686
): boolean {
8787
if (!respectQueryAndFragment) {
8888
return input.endsWith("/");
@@ -107,7 +107,7 @@ export function hasTrailingSlash(
107107
*/
108108
export function withoutTrailingSlash(
109109
input = "",
110-
respectQueryAndFragment?: boolean
110+
respectQueryAndFragment?: boolean,
111111
): string {
112112
if (!respectQueryAndFragment) {
113113
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
@@ -146,7 +146,7 @@ export function withoutTrailingSlash(
146146
*/
147147
export function withTrailingSlash(
148148
input = "",
149-
respectQueryAndFragment?: boolean
149+
respectQueryAndFragment?: boolean,
150150
): string {
151151
if (!respectQueryAndFragment) {
152152
return input.endsWith("/") ? input : input + "/";
@@ -283,7 +283,7 @@ export function withQuery(input: string, query: QueryObject): string {
283283
* @group utils
284284
*/
285285
export function getQuery<T extends ParsedQuery = ParsedQuery>(
286-
input: string
286+
input: string,
287287
): T {
288288
return parseQuery<T>(parseURL(input).search);
289289
}
@@ -506,7 +506,7 @@ export function normalizeURL(input: string): string {
506506
export function resolveURL(base = "", ...inputs: string[]): string {
507507
if (typeof base !== "string") {
508508
throw new TypeError(
509-
`URL input should be string received ${typeof base} (${base})`
509+
`URL input should be string received ${typeof base} (${base})`,
510510
);
511511
}
512512

‎test/normalize.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe("normalizeURL", () => {
9292
for (const input of validURLS) {
9393
test(input, () => {
9494
expect(withoutTrailingSlash(normalizeURL(input))).toBe(
95-
withoutTrailingSlash(new URL(input).href)
95+
withoutTrailingSlash(new URL(input).href),
9696
);
9797
});
9898
}

‎test/parse.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ describe("parseFilename", () => {
274274
for (const t of tests) {
275275
test(t.input.toString(), () => {
276276
expect(
277-
parseFilename(t.input[0].toString(), { strict: t.input[1] })
277+
parseFilename(t.input[0].toString(), { strict: t.input[1] }),
278278
).toStrictEqual(t.out);
279279
});
280280
}

‎test/resolve.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ describe("resolveURL", () => {
1919
test("invalid URL (null)", () => {
2020
// eslint-disable-next-line unicorn/no-null
2121
expect(() => resolveURL(null as any)).toThrow(
22-
"URL input should be string received object (null)"
22+
"URL input should be string received object (null)",
2323
);
2424
});
2525

2626
test("invalid URL (array)", () => {
2727
expect(() => resolveURL([])).toThrow(
28-
"URL input should be string received object ()"
28+
"URL input should be string received object ()",
2929
);
3030
});
3131

‎test/url.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ describe("$URL", () => {
3535

3636
test("append", () => {
3737
const url = new $URL(
38-
"https://john:doe@example.com:1080/path?query=value#hash"
38+
"https://john:doe@example.com:1080/path?query=value#hash",
3939
);
4040
const path = new $URL("/newpath?newquery=newvalue#newhash");
4141

4242
url.append(path);
4343

4444
expect(url.toString()).toEqual(
45-
"https://john:doe@example.com:1080/path/newpath?query=value&newquery=newvalue#newhash"
45+
"https://john:doe@example.com:1080/path/newpath?query=value&newquery=newvalue#newhash",
4646
);
4747
});
4848

‎test/utilities.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("hasProtocol", () => {
5353
expect(hasProtocol(t.input)).toBe(withDefault);
5454
expect(hasProtocol(t.input, { strict: true })).toBe(withStrict);
5555
expect(hasProtocol(t.input, { acceptRelative: true })).toBe(
56-
withAcceptRelative
56+
withAcceptRelative,
5757
);
5858
expect(hasProtocol(t.input, true)).toBe(withAcceptRelative);
5959
});
@@ -128,8 +128,8 @@ describe("stringifyParsedURL", () => {
128128
test(t.input.toString(), () => {
129129
expect(
130130
stringifyParsedURL(
131-
typeof t.input === "string" ? parsePath(t.input) : t.input
132-
)
131+
typeof t.input === "string" ? parsePath(t.input) : t.input,
132+
),
133133
).toBe(t.out);
134134
});
135135
}

0 commit comments

Comments
 (0)
Please sign in to comment.