summaryrefslogtreecommitdiff
path: root/cli/js/web/url.ts
diff options
context:
space:
mode:
authorStanislav <62983943+stanislavstrelnikov@users.noreply.github.com>2020-07-07 04:45:39 +0300
committerGitHub <noreply@github.com>2020-07-06 21:45:39 -0400
commit158ae0bfe900d2bac3076390c4fe3d2b54d94fe5 (patch)
tree209e4b5682e2a899041767c49428e34329e48084 /cli/js/web/url.ts
parentab4c574f5202f607ceb6068f56b3cc8aed1bbbaf (diff)
clean up code in cli/js (#6611)
Diffstat (limited to 'cli/js/web/url.ts')
-rw-r--r--cli/js/web/url.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts
index 60690d46a..b12f6da75 100644
--- a/cli/js/web/url.ts
+++ b/cli/js/web/url.ts
@@ -24,7 +24,7 @@ const searchParamsMethods: Array<keyof URLSearchParams> = [
const specialSchemes = ["ftp", "file", "http", "https", "ws", "wss"];
// https://url.spec.whatwg.org/#special-scheme
-const schemePorts: { [key: string]: string } = {
+const schemePorts: Record<string, string> = {
ftp: "21",
file: "",
http: "80",
@@ -179,8 +179,8 @@ function resolvePathFromBase(
let driveLetterPrefix = "";
if (build.os == "windows" && isFilePath) {
- let driveLetter = "";
- let baseDriveLetter = "";
+ let driveLetter: string;
+ let baseDriveLetter: string;
[driveLetter, normalizedPath] = takePattern(
normalizedPath,
/^(\/[A-Za-z]:)(?=\/)/
@@ -214,7 +214,8 @@ function resolvePathFromBase(
function isValidPort(value: string): boolean {
// https://url.spec.whatwg.org/#port-state
- if (value === "") true;
+ if (value === "") return true;
+
const port = Number(value);
return Number.isInteger(port) && port >= 0 && port <= MAX_PORT;
}
@@ -409,7 +410,7 @@ export class URLImpl implements URL {
let baseParts: URLParts | undefined;
if (base) {
baseParts = typeof base === "string" ? parse(base) : parts.get(base);
- if (baseParts == undefined) {
+ if (baseParts === undefined) {
throw new TypeError("Invalid base URL.");
}
}