Skip to content

Commit f70a32f

Browse files
committed
Remove path.posix.join
Since this is for file system paths it feels incorrect to use it on URL paths as they are different in many ways.
1 parent a0e928e commit f70a32f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/common/util.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export const generateUuid = (length = 24): string => {
2323

2424
/**
2525
* Remove extra slashes in a URL.
26+
*
27+
* This is meant to fill the job of `path.join` so you can concatenate paths and
28+
* then normalize out any extra slashes.
29+
*
30+
* If you are using `path.join` you do not need this but note that `path` is for
31+
* file system paths, not URLs.
2632
*/
2733
export const normalize = (url: string, keepTrailing = false): string => {
2834
return url.replace(/\/\/+/g, "/").replace(/\/+$/, keepTrailing ? "/" : "")

src/node/http.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as express from "express"
33
import * as expressCore from "express-serve-static-core"
44
import * as http from "http"
55
import * as net from "net"
6-
import path from "path"
76
import * as qs from "qs"
87
import { Disposable } from "../common/emitter"
98
import { CookieKeys, HttpCode, HttpError } from "../common/http"
@@ -18,7 +17,9 @@ import { getPasswordMethod, IsCookieValidArgs, isCookieValid, sanitizeString, es
1817
*/
1918
export interface ClientConfiguration {
2019
codeServerVersion: string
20+
/** Relative path from this page to the root. No trailing slash. */
2121
base: string
22+
/** Relative path from this page to the static root. No trailing slash. */
2223
csStaticBase: string
2324
}
2425

@@ -36,8 +37,8 @@ export const createClientConfiguration = (req: express.Request): ClientConfigura
3637
const base = relativeRoot(req.originalUrl)
3738

3839
return {
39-
base,
40-
csStaticBase: normalize(path.posix.join(base, "_static/")),
40+
base: base,
41+
csStaticBase: base + "/_static",
4142
codeServerVersion,
4243
}
4344
}

src/node/routes/vscode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class CodeServerRouteWrapper {
2424
const isAuthenticated = await authenticated(req)
2525

2626
if (!isAuthenticated) {
27-
return redirect(req, res, "login/", {
27+
return redirect(req, res, "login", {
2828
// req.baseUrl can be blank if already at the root.
2929
to: req.baseUrl && req.baseUrl !== "/" ? req.baseUrl : undefined,
3030
})

0 commit comments

Comments
 (0)