diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-01-01 23:18:03 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-01-01 23:18:03 -0400 |
commit | 0bb644e2a37ad63d86fe3b313d5f33059b3bdc43 (patch) | |
tree | ac3dcefcf53d9c5de73bd4df23b6ad2e89fb4ad4 /src/util | |
parent | 1b4a8e79e94d67444675b43c1a40c161b9d6b3db (diff) |
fix backwards slashes in hrefs on windows...
...while also not breaking the way we use the to() functions for actual output write paths!
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/urls.js | 21 |
1 files changed, 16 insertions, 5 deletions
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 = () => { |