diff options
| author | Teddy Wing | 2013-11-10 06:43:01 -0500 |
|---|---|---|
| committer | Teddy Wing | 2013-11-10 06:43:01 -0500 |
| commit | c4fd8cf89fa7f647c8f97b58812d4e0b0c6d47f6 (patch) | |
| tree | af54861b72e242cb21acfbe958095fda04f122e1 | |
| parent | 6d41687a9195791760bd815cdbe9775519c02ac2 (diff) | |
| download | clip-play-c4fd8cf89fa7f647c8f97b58812d4e0b0c6d47f6.tar.bz2 | |
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.
| -rw-r--r-- | assets/js/views/sample-add-view.js | 5 |
1 files 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' |
