diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/html.js | 8 | ||||
-rw-r--r-- | src/util/urls.js | 19 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/util/html.js b/src/util/html.js index f2456565..2468b8db 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -475,14 +475,6 @@ export class Attributes { throw new Error(`Attribute value for ${key} should be primitive or array, got ${typeof val}`); }) .filter(([_key, _val, keep]) => keep) - .map(([key, val]) => { - switch (key) { - case 'href': - return [key, encodeURI(val)]; - default: - return [key, val]; - } - }) .map(([key, val]) => typeof val === 'boolean' ? `${key}` 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}), }; }; |