Skip to content

Commit 71850e3

Browse files
committed
Avoid setting ?to=/
That's the default so it's extra visual noise.
1 parent b8340a2 commit 71850e3

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/node/routes/domainProxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ router.all("*", (req, res, next) => {
5555
}
5656
// Redirect all other pages to the login.
5757
return redirect(req, res, "login", {
58-
to: req.path,
58+
to: req.path !== "/" ? req.path : undefined,
5959
})
6060
}
6161

src/node/routes/pathProxy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Request, Router } from "express"
22
import qs from "qs"
33
import { HttpCode, HttpError } from "../../common/http"
4+
import { normalize } from "../../common/util"
45
import { authenticated, ensureAuthenticated, redirect } from "../http"
56
import { proxy } from "../proxy"
67
import { Router as WsRouter } from "../wsRouter"
@@ -17,11 +18,11 @@ const getProxyTarget = (req: Request, rewrite: boolean): string => {
1718

1819
router.all("/(:port)(/*)?", (req, res) => {
1920
if (!authenticated(req)) {
20-
// If visiting the root (/proxy/:port and nothing else) redirect to the
21-
// login page.
21+
// If visiting the root (/:port only) redirect to the login page.
2222
if (!req.params[0] || req.params[0] === "/") {
23+
const to = normalize(`${req.baseUrl}${req.path}`)
2324
return redirect(req, res, "login", {
24-
to: `${req.baseUrl}${req.path}` || "/",
25+
to: to !== "/" ? to : undefined,
2526
})
2627
}
2728
throw new HttpError("Unauthorized", HttpCode.Unauthorized)

src/node/routes/vscode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const vscode = new VscodeProvider()
1515
router.get("/", async (req, res) => {
1616
if (!authenticated(req)) {
1717
return redirect(req, res, "login", {
18-
to: req.baseUrl,
18+
// req.baseUrl can be blank if already at the root.
19+
to: req.baseUrl && req.baseUrl !== "/" ? req.baseUrl : undefined,
1920
})
2021
}
2122

0 commit comments

Comments
 (0)