Permalink
Browse files

Make url matching regexps case insensitive

  • Loading branch information...
Brent C
Brent C committed May 22, 2012
1 parent 11c6ac7 commit f45e4ac0c34fc88df0899413203aebcd5237796a
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/preview.js
View
@@ -89,14 +89,14 @@ function Preview(elem, options) {
}
// Simple regex to make sure the url with a scheme is valid.
- var urlexp = /^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
+ var urlexp = /^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i;
var matches = status.match(urlexp);
var url = matches? matches[0] : null;
//No urls is the status. Try for urls without scheme i.e. example.com
if (url === null) {
- urlexp = /[-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/g;
+ urlexp = /[-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/gi;
matches = status.match(urlexp);
url = matches? 'http://'+matches[0] : null;
}
@@ -374,4 +374,4 @@ function Preview(elem, options) {
//Return the Preview Function that will eventually be namespaced to $.preview.
return Preview;
-}
+}

0 comments on commit f45e4ac

Please sign in to comment.