Skip to content

Commit 6d23691

Browse files
Fix base URL.
Something evidently removes the trailing slash we add to PUBLIC_URL.
1 parent 1339a81 commit 6d23691

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/base.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const baseUrl = (() => {
2+
let base = process.env.PUBLIC_URL || "/";
3+
if (!base.endsWith("/")) {
4+
base += "/";
5+
}
6+
return base;
7+
})();

src/language-server/pyright.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
BrowserMessageReader,
99
BrowserMessageWriter,
1010
} from "vscode-jsonrpc/browser";
11+
import { baseUrl } from "../base";
1112
import { createUri, LanguageServerClient } from "./client";
1213

1314
// This is modified by bin/update-pyright.sh
@@ -24,9 +25,7 @@ export const pyright = (language: string): LanguageServerClient | undefined => {
2425
return undefined;
2526
}
2627
// Needed to support review branches that use a path location.
27-
const workerScript = `${
28-
process.env.PUBLIC_URL || "/"
29-
}workers/${workerScriptName}`;
28+
const workerScript = `${baseUrl}workers/${workerScriptName}`;
3029
const foreground = new Worker(workerScript, {
3130
name: "Pyright-foreground",
3231
});

src/router-hooks.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
useMemo,
2020
useState,
2121
} from "react";
22+
import { baseUrl } from "./base";
2223
import { useLogging } from "./logging/logging-hooks";
2324

2425
/**
@@ -79,8 +80,7 @@ const parse = (pathname: string, search: string): RouterState => {
7980
idea: anchorForParam(params.get("idea")),
8081
};
8182
}
82-
const base = process.env.PUBLIC_URL || "/";
83-
pathname = pathname.slice(base.length);
83+
pathname = pathname.slice(baseUrl.length);
8484
if (pathname) {
8585
const parts = pathname.split("/");
8686
const tab = parts[0];
@@ -123,8 +123,7 @@ export const toUrl = (state: RouterState): string => {
123123
(state.idea ? "ideas" : undefined),
124124
state.api?.id ?? state.reference?.id ?? state.idea?.id,
125125
];
126-
const base = process.env.PUBLIC_URL || "/";
127-
const pathname = base + parts.filter((x): x is string => !!x).join("/");
126+
const pathname = baseUrl + parts.filter((x): x is string => !!x).join("/");
128127
return window.location.toString().split("/", 1)[0] + pathname;
129128
};
130129

0 commit comments

Comments
 (0)