mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
feat(electron): fix windows path
This commit is contained in:
@@ -132,11 +132,17 @@
|
||||
[repo-url file content]
|
||||
(let [electron-local-repo? (and (util/electron?)
|
||||
(config/local-db? repo-url))
|
||||
;; FIXME: store relative path in db
|
||||
file (cond
|
||||
(and electron-local-repo? (util/win32?))
|
||||
(and electron-local-repo?
|
||||
util/win32?
|
||||
(utils/win32 file))
|
||||
file
|
||||
|
||||
electron-local-repo?
|
||||
(and electron-local-repo? util/win32?)
|
||||
(str (config/get-repo-dir repo-url) "/" file)
|
||||
|
||||
(and electron-local-repo? (not= "/" (first file)))
|
||||
(str (config/get-repo-dir repo-url) "/" file)
|
||||
|
||||
:else
|
||||
|
||||
@@ -192,3 +192,15 @@ export const reversePatch = patch => {
|
||||
length2: patchObj.length1
|
||||
}));
|
||||
};
|
||||
|
||||
// Copied from https://github.com/sindresorhus/path-is-absolute/blob/main/index.js
|
||||
export const win32 = path => {
|
||||
// https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
|
||||
var splitDeviceRe = /^([a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?([\\/])?([\s\S]*?)$/;
|
||||
var result = splitDeviceRe.exec(path);
|
||||
var device = result[1] || '';
|
||||
var isUnc = Boolean(device && device.charAt(1) !== ':');
|
||||
|
||||
// UNC paths are always absolute
|
||||
return Boolean(result[2] || isUnc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user