Skip to content

Commit

Permalink
fix: update and add missing URL regex condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixhin committed Oct 14, 2015
1 parent 039f141 commit a999f28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gulp.task("bump-version", function() {
gulp.task("commit-changes", function() {
return gulp.src(".")
.pipe(git.add())
.pipe(git.commit("[Prerelease] Bumped version number"));
.pipe(git.commit("chore: bump version number"));
});

gulp.task("push-changes", function(cb) {
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ app.post("/api/webhooks/register", jsonParser, function(req, res, next) {
var event = webhook.event;
var objId = webhook.id;

// Use John Gruber's URL regex
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;
// Validate
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;
console.log(url);
if (!url || !urlRegEx.test(url)) {
res.status(400);
return res.send({error: "Invalid or empty URL"});
} else if (objects !== "experiments") {
Expand Down

0 comments on commit a999f28

Please sign in to comment.