diff --git a/src/substitute.js b/src/substitute.js index 584c5ef..b25583b 100644 --- a/src/substitute.js +++ b/src/substitute.js @@ -1,21 +1,22 @@ import parse from './parse/index.js'; -const isEncoded = (serverVariable) => { +const isEncoded = (serverVariableValue) => { try { return ( - typeof serverVariable === 'string' && decodeURIComponent(serverVariable) !== serverVariable + typeof serverVariableValue === 'string' && + decodeURIComponent(serverVariableValue) !== serverVariableValue ); } catch { return false; } }; -export const encodeServerVariable = (serverVariable) => { - if (isEncoded(serverVariable)) { - return serverVariable; +export const encodeServerVariable = (serverVariableValue) => { + if (isEncoded(serverVariableValue)) { + return serverVariableValue; } - return encodeURIComponent(serverVariable).replace(/%5B/g, '[').replace(/%5D/g, ']'); + return encodeURIComponent(serverVariableValue).replace(/%5B/g, '[').replace(/%5D/g, ']'); }; const significantTypes = ['literals', 'server-variable-name']; diff --git a/src/test.js b/src/test.js index b101787..1b27190 100644 --- a/src/test.js +++ b/src/test.js @@ -3,7 +3,7 @@ import parse from './parse/index.js'; /** * Test if a string is a server URL template. * - * @param {string} str + * @param {string} serverURLTemplate * @param {Object} [options={}] - An object. * @param {boolean} [options.strict=true] - A boolean indicating presence of at least one `Server Variable` AST node. * @returns {boolean}