Skip to content

Commit

Permalink
fix(writevcl): guard against missing name
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Jul 1, 2020
1 parent f6180fa commit cd2afd4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/httpclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function create({ baseURL, timeout, headers }) {
time: true,
headers: myheaders,
};

const uri = `${baseURL}${path}`;

if (timeout) {
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,10 @@ class Fastly {
* @returns {Promise} The response object representing the completion or failure.
*/
async updateVCL(version, name, data) {
if (typeof name === 'object') {
data = name;
name = data.name;
}
return this.request.put(`/service/${this.service_id}/version/${await this.getVersion(version, 'current')}/vcl/${name}`, data);
}

Expand Down
14 changes: 14 additions & 0 deletions test/bodymatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = obj => str => {
const params = new URLSearchParams(str);
console.log(params, obj);
let match = true;
params.forEach((value, key) => {
match = match && obj[key] === value;
});

Object.entries(([key, value]) => {
match = match && params.get(key) === value;
});

return match;
}

0 comments on commit cd2afd4

Please sign in to comment.