diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-21 07:01:31 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-21 07:01:31 -0400 |
commit | 0807f466104c11033abe3e79c528cd409329415d (patch) | |
tree | 82cc14f82906c67294f5d3f26bb772f7dec06c34 /src/urls.js | |
parent | c8d6dd977fa65e0d72c0903c86a8526aa8ed1ac5 (diff) |
upd8: online thumbs cache
This code is actually from January 17th.
Diffstat (limited to 'src/urls.js')
-rw-r--r-- | src/urls.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/urls.js b/src/urls.js index faa58237..83a8b904 100644 --- a/src/urls.js +++ b/src/urls.js @@ -53,15 +53,7 @@ export function generateURLs(urlSpec) { const rebasePrefix = '../'.repeat(fromPrefix.split('/').filter(Boolean).length); - const originOfPrefix = prefix => { - try { - return new URL(prefix).origin; - } catch { - return null; - } - }; - - const fromOrigin = originOfPrefix(fromPrefix); + const fromOrigin = getOrigin(fromPrefix); const pathHelper = (toPath, toGroup) => { let B = trimLeadingSlash(toPath); @@ -74,9 +66,9 @@ export function generateURLs(urlSpec) { const toPrefix = toGroup.prefix; if (toPrefix !== fromPrefix) { - // Compare origins. Note that originOfPrefix() can + // Compare origins. Note that getOrigin() can // be null for both prefixes. - const toOrigin = originOfPrefix(toPrefix); + const toOrigin = getOrigin(toPrefix); if (fromOrigin === toOrigin) { // Go to the root, add the to-group's prefix, then // continue with normal path.relative() behavior. @@ -233,6 +225,14 @@ export function generateURLs(urlSpec) { return generateFrom(); } +export function getOrigin(prefix) { + try { + return new URL(prefix).origin; + } catch { + return null; + } +} + const thumbnailHelper = (name) => (file) => file.replace(/\.(jpg|png)$/, name + '.jpg'); |