Skip to content

Commit 4b6a300

Browse files
committed
feat(utils): Add getRemoteUrl fn.
1 parent 2f41571 commit 4b6a300

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utils/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,17 @@ export class Utils
245245
const list = plugin.app.vault.getRoot().children;
246246
return list.filter(fileOrFolder => (fileOrFolder instanceof TFolder)).map(folder => folder.path)
247247
}
248+
249+
static getRemoteUrl(file: TFile, domain: string) {
250+
let url = domain || '';
251+
if (!url.endsWith('/')) {
252+
url += '/'
253+
}
254+
if (file.path.endsWith('.md')) {
255+
url += file.path.replace(/\.md$/ig, '');
256+
} else {
257+
url += file.path;
258+
}
259+
return url;
260+
}
248261
}

0 commit comments

Comments
 (0)