Skip to content

Commit dc97b9e

Browse files
authored
refactor: align naming with OpenAPI nomenclature (#16)
1 parent d9d51cc commit dc97b9e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/substitute.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import parse from './parse/index.js';
22

3-
const isEncoded = (serverVariable) => {
3+
const isEncoded = (serverVariableValue) => {
44
try {
55
return (
6-
typeof serverVariable === 'string' && decodeURIComponent(serverVariable) !== serverVariable
6+
typeof serverVariableValue === 'string' &&
7+
decodeURIComponent(serverVariableValue) !== serverVariableValue
78
);
89
} catch {
910
return false;
1011
}
1112
};
1213

13-
export const encodeServerVariable = (serverVariable) => {
14-
if (isEncoded(serverVariable)) {
15-
return serverVariable;
14+
export const encodeServerVariable = (serverVariableValue) => {
15+
if (isEncoded(serverVariableValue)) {
16+
return serverVariableValue;
1617
}
1718

18-
return encodeURIComponent(serverVariable).replace(/%5B/g, '[').replace(/%5D/g, ']');
19+
return encodeURIComponent(serverVariableValue).replace(/%5B/g, '[').replace(/%5D/g, ']');
1920
};
2021

2122
const significantTypes = ['literals', 'server-variable-name'];

src/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import parse from './parse/index.js';
33
/**
44
* Test if a string is a server URL template.
55
*
6-
* @param {string} str
6+
* @param {string} serverURLTemplate
77
* @param {Object} [options={}] - An object.
88
* @param {boolean} [options.strict=true] - A boolean indicating presence of at least one `Server Variable` AST node.
99
* @returns {boolean}

0 commit comments

Comments
 (0)