From 0807f466104c11033abe3e79c528cd409329415d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 21 Jan 2025 07:01:31 -0400 Subject: upd8: online thumbs cache This code is actually from January 17th. --- src/urls.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/urls.js') 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'); -- cgit 1.3.0-6-gf8a5