mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-07 22:19:02 +00:00
electron fs: use notion:// for api reqs instead of http://
This commit is contained in:
parent
a44ae9f4f1
commit
50a77d05a1
8
insert/env/fs.mjs
vendored
8
insert/env/fs.mjs
vendored
@ -32,7 +32,9 @@ export const localPath = (path) => `notion://www.notion.so/__notion-enhancer/${p
|
||||
* @returns {object} the json value of the requested file as a js object
|
||||
*/
|
||||
export const getJSON = (path, opts = {}) => {
|
||||
if (path.startsWith('http')) return fetch(path, opts).then((res) => res.json());
|
||||
path = path.replace(/^https:\/\/www\.notion\.so\//, 'notion://www.notion.so/');
|
||||
const networkPath = path.startsWith('http') || path.startsWith('notion://');
|
||||
if (networkPath) return fetch(path, opts).then((res) => res.json());
|
||||
try {
|
||||
return globalThis.__enhancerElectronApi.nodeRequire(`notion-enhancer/${path}`);
|
||||
} catch (err) {
|
||||
@ -47,7 +49,9 @@ export const getJSON = (path, opts = {}) => {
|
||||
* @returns {string} the text content of the requested file
|
||||
*/
|
||||
export const getText = (path, opts = {}) => {
|
||||
if (path.startsWith('http')) return fetch(path, opts).then((res) => res.text());
|
||||
path = path.replace(/^https:\/\/www\.notion\.so\//, 'notion://www.notion.so/');
|
||||
const networkPath = path.startsWith('http') || path.startsWith('notion://');
|
||||
if (networkPath) return fetch(path, opts).then((res) => res.text());
|
||||
try {
|
||||
const fs = globalThis.__enhancerElectronApi.nodeRequire('fs');
|
||||
return fs.readFileSync(notionPath(`notion-enhancer/${path}`));
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 33d70f998901cf1c9cbf857f68c1d2bf4d5c8ceb
|
||||
Subproject commit 5a039543b275503ee0df6a888390821dae9807b4
|
Loading…
Reference in New Issue
Block a user