aboutsummaryrefslogtreecommitdiffstats
path: root/src/asset-url.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-01 16:34:55 -0700
committerAdam Soltys <[email protected]>2026-10-01 16:34:55 -0700
commit66d41d1aa1f5c60cd63b1691ba6bf70e88cf78fa (patch)
treeb26348dfe27873e9bd610b67a5880de00cf3db72 /src/asset-url.js
parenta7806172f7ede9be345750c93e5fa72e10e9b953 (diff)
downloadcoinosv3-66d41d1aa1f5c60cd63b1691ba6bf70e88cf78fa.tar.gz
coinosv3-66d41d1aa1f5c60cd63b1691ba6bf70e88cf78fa.zip
The standalone wallet opened from a disk shows its avatars, font and languages.
With no files beside it, relative punks/, locales/, nip46.js and jsqr.js looked on the disk. From file:// they now come from v3.coinos.io (images and scripts need no CORS; /locales/ now sends Access-Control-Allow-Origin on the server), and standalone.html carries Public Sans inline. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VP5Ljqk7EYcm5QQAbzDwog
Diffstat (limited to 'src/asset-url.js')
-rw-r--r--src/asset-url.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/asset-url.js b/src/asset-url.js
new file mode 100644
index 0000000..bd80240
--- /dev/null
+++ b/src/asset-url.js
@@ -0,0 +1,6 @@
+// The standalone wallet (standalone.html opened from a disk) has no files
+// beside it: punks, the lazy modules and the language packs come from the
+// site instead. Served from anywhere else, paths stay relative.
+export const SITE = 'https://v3.coinos.io/';
+const fromDisk = () => typeof location !== 'undefined' && location.protocol === 'file:';
+export const assetUrl = (path) => fromDisk() ? SITE + path.replace(/^\//, '') : path;