-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (39 loc) · 1.19 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const log = (...args) => {
if (log.enabled) {
console.log("[pathParam]", ...args);
}
};
log.enabled = false;
const pathParameterTag = {
name: "pathParam",
displayName: "Path parameter",
liveDisplayName(args) {
const name = args[0].value;
return name ? name : args[1].value;
},
description: "replace part of URI path with given value",
args: [
{
displayName: "Display name",
description: "Optional name to display instead of value in Insomnia UI. Doesn't affect the request made.",
type: "string"
}, {
displayName: "Value",
description: "Value of the path parameter",
type: "string"
}, {
displayName: "Description",
description: "Optional description of this parameter, which doesn't affect the request made",
type: "string"
}, {
displayName: "URI Encode",
description: "Select to URI encode the parameter",
type: "boolean",
defaultValue: true
}
],
async run(context, name, value, description, mustEncode) {
return mustEncode ? encodeURIComponent(value) : value;
}
};
module.exports.templateTags = [pathParameterTag];