clean up code in cli/js (#6611)

This commit is contained in:
Stanislav 2020-07-07 04:45:39 +03:00 committed by GitHub
parent ab4c574f52
commit 158ae0bfe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 395 additions and 354 deletions

View file

@ -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.");
}
}