Skip to content

Commit

Permalink
Uppercase HTTP method and ad user agent string
Browse files Browse the repository at this point in the history
  • Loading branch information
tobie committed Feb 3, 2024
1 parent ca04bd6 commit bd4c8a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/fetch-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const request = require("request");

module.exports = (url, service) => {
return new Promise((resolve, reject) => {
if (typeof url == "string") {
url = { url };
}
url.headers = { "User-Agent": "pr-preview" };
request(url, function (error, response, body) {
if (error) {
error.data = { request_url: url, service: service };
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/fetchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = (superclass) => class extends superclass {
getBikeshedUrl(data) {
let query = this.getQuery(data, "&", true);
return {
method: "post",
method: "POST",
url: `https://api.csswg.org/bikeshed/?url=${ urlencode(this.github_url) }${ query }`
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/models/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ suite("Branch model", function() {
src_file: "index.bs"
};
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
method: "POST",
url: BIKESHED_URL + "index.bs"
});
});
Expand All @@ -155,7 +155,7 @@ suite("Branch model", function() {
};

assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
method: "POST",
url: BIKESHED_URL + "url.bs"
});
});
Expand All @@ -168,7 +168,7 @@ suite("Branch model", function() {
params: { "md-status": "REC" }
};
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
method: "POST",
url: BIKESHED_URL + "index.bs&md-status=REC"
});
});
Expand All @@ -184,7 +184,7 @@ suite("Branch model", function() {
}
};
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
method: "POST",
url: BIKESHED_URL + "index.bs&md-title=FOO%20BAR%20tobie%2Fwebidl%2Finterface-objs%23283-7dfd134"
});
});
Expand All @@ -199,7 +199,7 @@ suite("Branch model", function() {
}
};
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
method: "POST",
url: BIKESHED_URL + "index.bs&force=1"
});
});
Expand Down

0 comments on commit bd4c8a4

Please sign in to comment.