BUGFIX: Documentation navigator does not handle external URL properly (#2202)

This commit is contained in:
catloversg
2025-06-22 03:31:52 +07:00
committed by GitHub
parent f2e539bea5
commit 510a9a6be5
14 changed files with 139 additions and 78 deletions
+9 -3
View File
@@ -28,6 +28,7 @@ export const defaultNsApiPage = asFilePath("nsDoc/bitburner.ns.md");
*/
export const externalUrlOfNsApiPage =
"https://github.com/bitburner-official/bitburner-src/blob/stable/markdown/bitburner.ns.md";
export const prefixOfHttpUrlOfNsDocs = "https://github.com/bitburner-official/bitburner-src/blob/stable/markdown/";
const HistoryContext = React.createContext<History>({
page: defaultPage,
@@ -92,8 +93,13 @@ export const HistoryProvider = (props: React.PropsWithChildren<object>): React.R
export function openDocExternally(path: string) {
const ver = CONSTANTS.isDevBranch ? "dev" : "stable";
const url = path.startsWith("nsDoc/")
? `https://github.com/bitburner-official/bitburner-src/blob/${ver}/markdown/${path.replace("nsDoc/", "")}`
: `https://github.com/bitburner-official/bitburner-src/blob/${ver}/src/Documentation/doc/${path}`;
let url;
if (path.startsWith("http://") || path.startsWith("https://")) {
url = path;
} else if (path.startsWith("nsDoc/")) {
url = `https://github.com/bitburner-official/bitburner-src/blob/${ver}/markdown/${path.replace("nsDoc/", "")}`;
} else {
url = `https://github.com/bitburner-official/bitburner-src/blob/${ver}/src/Documentation/doc/${path}`;
}
window.open(url, "_newtab");
}