From c4fd8cf89fa7f647c8f97b58812d4e0b0c6d47f6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 10 Nov 2013 06:43:01 -0500 Subject: Adopt a simpler URL validation regex Gruber's would match any string as long as there was a valid URL inside them, which is not what we want. Use a simpler regex that matches URLs and only URLs. --- assets/js/views/sample-add-view.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/js/views/sample-add-view.js b/assets/js/views/sample-add-view.js index 2d3372e..8be2fb8 100644 --- a/assets/js/views/sample-add-view.js +++ b/assets/js/views/sample-add-view.js @@ -1,8 +1,7 @@ ClipPlay.Views.SampleAddView = Marionette.View.extend({ // Copied from - // http://daringfireball.net/2010/07/improved_regex_for_matching_urls - // http://stackoverflow.com/questions/6927719/url-regex-does-not-work-in-javascript - url_matcher: /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i, + // http://stackoverflow.com/a/10430654 + url_matcher: /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/, events: { 'click .js-create-sample': 'on_sample_add' -- cgit v1.2.3