diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-14 12:45:07 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-14 12:45:07 -0300 |
commit | b34828921179b53434db4fa93a72dd52e5f72fa5 (patch) | |
tree | 94ee7fb4e49b06c683506c1566f1c4720a3cfbe5 /src/util/urls.js | |
parent | 6f1d669e88cf0d92d73267291e2f70138e965c1f (diff) | |
parent | d3315efaf0cfb481fa32a8ea1739431f32aa1a98 (diff) |
Merge branch 'url-special-chars' into data-steps
Diffstat (limited to 'src/util/urls.js')
-rw-r--r-- | src/util/urls.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/util/urls.js b/src/util/urls.js index c2119b8d..4d099acd 100644 --- a/src/util/urls.js +++ b/src/util/urls.js @@ -79,16 +79,25 @@ export function generateURLs(urlSpec) { ); const toHelper = - (delimiterMode) => + ({device}) => (key, ...args) => { const { - value: {[delimiterMode]: template}, + value: { + [device ? 'device' : 'posix']: template, + }, } = getValueForFullKey(relative, key); let missing = 0; let result = template.replaceAll(/<([0-9]+)>/g, (match, n) => { if (n < args.length) { - return args[n]; + const value = args[n]; + if (device) { + return value; + } else { + let encoded = encodeURIComponent(value); + encoded = encoded.replaceAll('%2F', '/'); + return encoded; + } } else { missing++; } @@ -106,8 +115,8 @@ export function generateURLs(urlSpec) { }; return { - to: toHelper('posix'), - toDevice: toHelper('device'), + to: toHelper({device: false}), + toDevice: toHelper({device: true}), }; }; |