Skip to content

Commit b478fdb

Browse files
committed
yarn prettier
1 parent bb144f7 commit b478fdb

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

src/node/cli.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -573,21 +573,21 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
573573
delete process.env.GITHUB_TOKEN
574574

575575
// Filter duplicate proxy domains and remove any leading `*.`.
576-
const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, "")));
577-
let finalProxies = [];
576+
const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, "")))
577+
const finalProxies = []
578578

579-
for(let proxyDomain of proxyDomains) {
579+
for (const proxyDomain of proxyDomains) {
580580
if (!proxyDomain.includes("{{port}}")) {
581-
finalProxies.push("{{port}}." + proxyDomain);
581+
finalProxies.push("{{port}}." + proxyDomain)
582582
} else {
583-
finalProxies.push(proxyDomain);
583+
finalProxies.push(proxyDomain)
584584
}
585585
}
586586

587587
// all proxies are of format anyprefix-{{port}}-anysuffix.{{host}}, where {{host}} is optional
588588
// e.g. code-8080.domain.tld would match for code-{{port}}.domain.tld and code-{{port}}.{{host}}
589589
if (finalProxies.length > 0 && !process.env.VSCODE_PROXY_URI) {
590-
process.env.VSCODE_PROXY_URI = `//${finalProxies[0]}`;
590+
process.env.VSCODE_PROXY_URI = `//${finalProxies[0]}`
591591
}
592592
args["proxy-domain"] = finalProxies
593593

src/node/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const runCodeServer = async (
151151
logger.info(` - ${plural(args["proxy-domain"].length, "Proxying the following domain")}:`)
152152
args["proxy-domain"].forEach((domain) => logger.info(` - ${domain}`))
153153
}
154-
if(process.env.VSCODE_PROXY_URI) {
154+
if (process.env.VSCODE_PROXY_URI) {
155155
logger.info(`Using proxy URI in PORTS tab: ${process.env.VSCODE_PROXY_URI}`)
156156
}
157157

src/node/routes/domainProxy.ts

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
11
import { Request, Router } from "express"
22
import { HttpCode, HttpError } from "../../common/http"
3-
import { getHost } from "../http"
4-
import { authenticated, ensureAuthenticated, ensureOrigin, redirect, self } from "../http"
3+
import { getHost, authenticated, ensureAuthenticated, ensureOrigin, redirect, self } from "../http"
54
import { proxy } from "../proxy"
65
import { Router as WsRouter } from "../wsRouter"
76

87
export const router = Router()
98

109
const proxyDomainToRegex = (matchString: string): RegExp => {
11-
let escapedMatchString = matchString.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
10+
const escapedMatchString = matchString.replace(/[.*+?^$()|[\]\\]/g, "\\$&")
1211

1312
// Replace {{port}} with a regex group to capture the port
1413
// Replace {{host}} with .+ to allow any host match (so rely on DNS record here)
15-
let regexString = escapedMatchString.replace("{{port}}", "(\\d+)");
16-
regexString = regexString.replace("{{host}}", ".+");
14+
let regexString = escapedMatchString.replace("{{port}}", "(\\d+)")
15+
regexString = regexString.replace("{{host}}", ".+")
1716

18-
regexString = regexString.replace(/[{}]/g, "\\$&"); //replace any '{}' that might be left
17+
regexString = regexString.replace(/[{}]/g, "\\$&") //replace any '{}' that might be left
1918

20-
return new RegExp("^" + regexString + "$");
19+
return new RegExp("^" + regexString + "$")
2120
}
2221

23-
let proxyRegexes : RegExp[] = [];
24-
const proxyDomainsToRegex = (proxyDomains : string[]): RegExp[] => {
25-
if(proxyDomains.length !== proxyRegexes.length) {
26-
proxyRegexes = proxyDomains.map(proxyDomainToRegex);
22+
let proxyRegexes: RegExp[] = []
23+
const proxyDomainsToRegex = (proxyDomains: string[]): RegExp[] => {
24+
if (proxyDomains.length !== proxyRegexes.length) {
25+
proxyRegexes = proxyDomains.map(proxyDomainToRegex)
2726
}
28-
return proxyRegexes;
27+
return proxyRegexes
2928
}
3029

3130
/**
3231
* Return the port if the request should be proxied.
33-
*
32+
*
3433
* The proxy-domain should be of format anyprefix-{{port}}-anysuffix.{{host}}, where {{host}} is optional
3534
* e.g. code-8080.domain.tld would match for code-{{port}}.domain.tld and code-{{port}}.{{host}}.
36-
*
35+
*
3736
*/
3837
const maybeProxy = (req: Request): string | undefined => {
39-
let reqDomain = getHost(req);
38+
const reqDomain = getHost(req)
4039
if (reqDomain === undefined) {
41-
return undefined;
40+
return undefined
4241
}
4342

44-
let regexs = proxyDomainsToRegex(req.args["proxy-domain"]);
43+
const regexs = proxyDomainsToRegex(req.args["proxy-domain"])
4544

46-
for(let regex of regexs){
47-
let match = reqDomain.match(regex);
45+
for (const regex of regexs) {
46+
const match = reqDomain.match(regex)
4847

4948
if (match) {
50-
return match[1]; // match[1] contains the port
49+
return match[1] // match[1] contains the port
5150
}
5251
}
5352

0 commit comments

Comments
 (0)