Merge pull request #3017 from Rummskartoffel/patch-1

Fix #3016
This commit is contained in:
Oliver Blanthorn 2020-11-23 20:48:51 +00:00 committed by GitHub
commit e30385eba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View file

@ -4745,7 +4745,7 @@ async function js_helper(str: string[]) {
let sourcePath = jsContent let sourcePath = jsContent
if (fromRC) { if (fromRC) {
const sep = "/" const sep = "/"
const rcPath = (await Native.getrcpath()).split(sep).slice(0, -1) const rcPath = (await Native.getrcpath("unix")).split(sep).slice(0, -1)
sourcePath = [...rcPath, sourcePath].join(sep) sourcePath = [...rcPath, sourcePath].join(sep)
} }
const file = await Native.read(sourcePath) const file = await Native.read(sourcePath)

View file

@ -58,11 +58,15 @@ async function sendNativeMsg(
} }
} }
export async function getrcpath(): Promise<string> { export async function getrcpath(separator: "unix" | "auto" = "auto"): Promise<string> {
const res = await sendNativeMsg("getconfigpath", {}) const res = await sendNativeMsg("getconfigpath", {})
if (res.code !== 0) throw new Error("getrcpath error: " + res.code) if (res.code !== 0) throw new Error("getrcpath error: " + res.code)
if (separator == "unix" && (await browserBg.runtime.getPlatformInfo()).os == "win") {
return res.content.replace(/\\/g, "/")
}
else
return res.content return res.content
} }