import Ember from 'ember';

// URL regex courtesy of https://github.com/kevva/url-regex
function urlRegex () {
  return /(?:^|\s)(["'])?(?:(?:(?:(?:https?|ftp|\w):)?\/\/)|(?:www.))(?:\S+(?::\S*)?@)?(?:(?:[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*)?\1/ig;
}

// Shortens the URL and adds three dots to the end
function shortenUrl ( url , length ) {
  
  if( !Ember.isBlank( url ) ) {
      url = url.substr( 0 , length ) + "..."; 
  }

  return url;
}

export { urlRegex, shortenUrl };
@@ -275,25 +275,16 @@
 (?:%5C.(?:
-%5B1-9%5D%5Cd?%7C
 1%5Cd%5Cd%7C2%5B
@@ -297,16 +297,25 @@
 %7C25%5B0-4%5D
+%7C%5B1-9%5D%5Cd?
 ))%7C(?:(?
@@ -478,16 +478,24 @@
 /%5CS*)?%5C1
+(?:$%7C%5Cs)
 /ig;%0A%7D%0A%0A
@@ -584,18 +584,16 @@
 gth ) %7B%0A
-  
 %0A  if( !
@@ -662,17 +662,16 @@
 + %22...%22;
- 
 %0A  %7D%0A%0A  
@@ -717,8 +717,9 @@
 enUrl %7D;
+%0A

support all ip addresses