mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 15:17:48 +02:00
BUGFIX: Documentation navigator does not handle external URL properly (#2202)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user