Skip to content

Commit a999f28

Browse files
committed
fix: update and add missing URL regex condition
1 parent 039f141 commit a999f28

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ gulp.task("bump-version", function() {
3636
gulp.task("commit-changes", function() {
3737
return gulp.src(".")
3838
.pipe(git.add())
39-
.pipe(git.commit("[Prerelease] Bumped version number"));
39+
.pipe(git.commit("chore: bump version number"));
4040
});
4141

4242
gulp.task("push-changes", function(cb) {

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,10 @@ app.post("/api/webhooks/register", jsonParser, function(req, res, next) {
365365
var event = webhook.event;
366366
var objId = webhook.id;
367367

368+
// Use John Gruber's URL regex
369+
var urlRegEx = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)\S+(?:[^\s`!\[\]{};:'".,?«»]))/ig;
368370
// Validate
369-
var urlRegExp = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i;
370-
console.log(url);
371+
if (!url || !urlRegEx.test(url)) {
371372
res.status(400);
372373
return res.send({error: "Invalid or empty URL"});
373374
} else if (objects !== "experiments") {

0 commit comments

Comments
 (0)