diff --git a/.prettierrc b/.prettierrc index 757fd64c..0967ef42 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1 @@ -{ - "trailingComma": "es5" -} +{} diff --git a/src/parse.ts b/src/parse.ts index 37d58082..ce5e8119 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -46,7 +46,7 @@ export interface ParsedHost { */ export function parseURL(input = "", defaultProto?: string): ParsedURL { const _specialProtoMatch = input.match( - /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i + /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i, ); if (_specialProtoMatch) { const [, _proto, _pathname = ""] = _specialProtoMatch; @@ -71,7 +71,7 @@ export function parseURL(input = "", defaultProto?: string): ParsedURL { .match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || []; const [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || []; const { pathname, search, hash } = parsePath( - path.replace(/\/(?=[A-Za-z]:)/, "") + path.replace(/\/(?=[A-Za-z]:)/, ""), ); return { diff --git a/src/query.ts b/src/query.ts index 82fafd89..306cb6ea 100644 --- a/src/query.ts +++ b/src/query.ts @@ -29,7 +29,7 @@ export type ParsedQuery = Record; * @group Query_utils */ export function parseQuery( - parametersString = "" + parametersString = "", ): T { const object: ParsedQuery = {}; if (parametersString[0] === "?") { @@ -65,7 +65,7 @@ export function parseQuery( */ export function encodeQueryItem( key: string, - value: QueryValue | QueryValue[] + value: QueryValue | QueryValue[], ): string { if (typeof value === "number" || typeof value === "boolean") { value = String(value); diff --git a/src/url.ts b/src/url.ts index bfc1b7fa..2cf9ffdf 100644 --- a/src/url.ts +++ b/src/url.ts @@ -23,7 +23,7 @@ export class $URL implements URL { constructor(input = "") { if (typeof input !== "string") { throw new TypeError( - `URL input should be string received ${typeof input} (${input})` + `URL input should be string received ${typeof input} (${input})`, ); } @@ -77,7 +77,7 @@ export class $URL implements URL { } else { p.append( name, - typeof value === "string" ? value : JSON.stringify(value) + typeof value === "string" ? value : JSON.stringify(value), ); } } diff --git a/src/utils.ts b/src/utils.ts index 8dce2932..ae60d2be 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -43,16 +43,16 @@ export interface HasProtocolOptions { */ export function hasProtocol( inputString: string, - opts?: HasProtocolOptions + opts?: HasProtocolOptions, ): boolean; /** @deprecated Same as { hasProtocol(inputString, { acceptRelative: true }) */ export function hasProtocol( inputString: string, - acceptRelative: boolean + acceptRelative: boolean, ): boolean; export function hasProtocol( inputString: string, - opts: boolean | HasProtocolOptions = {} + opts: boolean | HasProtocolOptions = {}, ): boolean { if (typeof opts === "boolean") { opts = { acceptRelative: opts }; @@ -82,7 +82,7 @@ export function isScriptProtocol(protocol?: string) { */ export function hasTrailingSlash( input = "", - respectQueryAndFragment?: boolean + respectQueryAndFragment?: boolean, ): boolean { if (!respectQueryAndFragment) { return input.endsWith("/"); @@ -107,7 +107,7 @@ export function hasTrailingSlash( */ export function withoutTrailingSlash( input = "", - respectQueryAndFragment?: boolean + respectQueryAndFragment?: boolean, ): string { if (!respectQueryAndFragment) { return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/"; @@ -146,7 +146,7 @@ export function withoutTrailingSlash( */ export function withTrailingSlash( input = "", - respectQueryAndFragment?: boolean + respectQueryAndFragment?: boolean, ): string { if (!respectQueryAndFragment) { return input.endsWith("/") ? input : input + "/"; @@ -283,7 +283,7 @@ export function withQuery(input: string, query: QueryObject): string { * @group utils */ export function getQuery( - input: string + input: string, ): T { return parseQuery(parseURL(input).search); } @@ -506,7 +506,7 @@ export function normalizeURL(input: string): string { export function resolveURL(base = "", ...inputs: string[]): string { if (typeof base !== "string") { throw new TypeError( - `URL input should be string received ${typeof base} (${base})` + `URL input should be string received ${typeof base} (${base})`, ); } diff --git a/test/normalize.test.ts b/test/normalize.test.ts index ea27a02f..ff0cecf5 100644 --- a/test/normalize.test.ts +++ b/test/normalize.test.ts @@ -92,7 +92,7 @@ describe("normalizeURL", () => { for (const input of validURLS) { test(input, () => { expect(withoutTrailingSlash(normalizeURL(input))).toBe( - withoutTrailingSlash(new URL(input).href) + withoutTrailingSlash(new URL(input).href), ); }); } diff --git a/test/parse.test.ts b/test/parse.test.ts index 419636c5..69c7c59f 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -274,7 +274,7 @@ describe("parseFilename", () => { for (const t of tests) { test(t.input.toString(), () => { expect( - parseFilename(t.input[0].toString(), { strict: t.input[1] }) + parseFilename(t.input[0].toString(), { strict: t.input[1] }), ).toStrictEqual(t.out); }); } diff --git a/test/resolve.test.ts b/test/resolve.test.ts index 8baf54f3..eb539b75 100644 --- a/test/resolve.test.ts +++ b/test/resolve.test.ts @@ -19,13 +19,13 @@ describe("resolveURL", () => { test("invalid URL (null)", () => { // eslint-disable-next-line unicorn/no-null expect(() => resolveURL(null as any)).toThrow( - "URL input should be string received object (null)" + "URL input should be string received object (null)", ); }); test("invalid URL (array)", () => { expect(() => resolveURL([])).toThrow( - "URL input should be string received object ()" + "URL input should be string received object ()", ); }); diff --git a/test/url.test.ts b/test/url.test.ts index 3c1384b0..a30714c0 100644 --- a/test/url.test.ts +++ b/test/url.test.ts @@ -35,14 +35,14 @@ describe("$URL", () => { test("append", () => { const url = new $URL( - "https://john:doe@example.com:1080/path?query=value#hash" + "https://john:doe@example.com:1080/path?query=value#hash", ); const path = new $URL("/newpath?newquery=newvalue#newhash"); url.append(path); expect(url.toString()).toEqual( - "https://john:doe@example.com:1080/path/newpath?query=value&newquery=newvalue#newhash" + "https://john:doe@example.com:1080/path/newpath?query=value&newquery=newvalue#newhash", ); }); diff --git a/test/utilities.test.ts b/test/utilities.test.ts index 9da85eeb..d288f6dc 100644 --- a/test/utilities.test.ts +++ b/test/utilities.test.ts @@ -53,7 +53,7 @@ describe("hasProtocol", () => { expect(hasProtocol(t.input)).toBe(withDefault); expect(hasProtocol(t.input, { strict: true })).toBe(withStrict); expect(hasProtocol(t.input, { acceptRelative: true })).toBe( - withAcceptRelative + withAcceptRelative, ); expect(hasProtocol(t.input, true)).toBe(withAcceptRelative); }); @@ -128,8 +128,8 @@ describe("stringifyParsedURL", () => { test(t.input.toString(), () => { expect( stringifyParsedURL( - typeof t.input === "string" ? parsePath(t.input) : t.input - ) + typeof t.input === "string" ? parsePath(t.input) : t.input, + ), ).toBe(t.out); }); }