diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/upd8.js | 6 | ||||
-rw-r--r-- | src/util/urls.js | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/upd8.js b/src/upd8.js index 29063f87..daef1458 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2023,8 +2023,8 @@ writePage.paths = (baseDirectory, fullKey, directory = '', { const [ groupKey, subKey ] = fullKey.split('.'); const pathname = (groupKey === 'localized' && baseDirectory - ? urls.from('shared.root').to('localizedWithBaseDirectory.' + subKey, baseDirectory, directory) - : urls.from('shared.root').to(fullKey, directory)); + ? urls.from('shared.root').toDevice('localizedWithBaseDirectory.' + subKey, baseDirectory, directory) + : urls.from('shared.root').toDevice(fullKey, directory)); // Needed for the rare directory which itself contains a slash, e.g. for // listings, with directories like 'albums/by-name'. @@ -2048,7 +2048,7 @@ function writeSymlinks() { ]); async function link(directory, urlKey) { - const pathname = urls.from('shared.root').to(urlKey); + const pathname = urls.from('shared.root').toDevice(urlKey); const file = path.join(outputPath, pathname); try { await unlink(file); diff --git a/src/util/urls.js b/src/util/urls.js index f0f9cdb1..5f1d6eb0 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -48,8 +48,12 @@ export function generateURLs(urlSpec) { target = rebasePrefix + (toGroup.prefix || '') + target; } - return (path.relative(fromPath, target) - + (toPath.endsWith('/') ? '/' : '')); + const suffix = (toPath.endsWith('/') ? '/' : ''); + + return { + posix: path.posix.relative(fromPath, target) + suffix, + device: path.relative(fromPath, target) + suffix + }; }; const groupSymbol = Symbol(); @@ -63,8 +67,12 @@ export function generateURLs(urlSpec) { const relative = withEntries(urlSpec, entries => entries .map(([key, urlGroup]) => [key, groupHelper(urlGroup)])); - const to = (key, ...args) => { - const { value: template, group: {[groupSymbol]: toGroup} } = getValueForFullKey(relative, key) + const toHelper = (delimiterMode) => (key, ...args) => { + const { + value: {[delimiterMode]: template}, + group: {[groupSymbol]: toGroup} + } = getValueForFullKey(relative, key); + let result = template.replaceAll(/<([0-9]+)>/g, (match, n) => args[n]); // Kinda hacky lol, 8ut it works. @@ -76,7 +84,10 @@ export function generateURLs(urlSpec) { return result; }; - return {to, relative}; + return { + to: toHelper('posix'), + toDevice: toHelper('device') + }; }; const generateFrom = () => { |