first things first, want adjust pattern angular uses match against url routing. have found function , running url location against these regex(s) found on line 5612 of angular.js (version http://code.angularjs.org/1.1.5/):
server_match = /^([^:]+):\/\/(\w+:{0,1}\w*@)?(\{?[\w\.-]*\}?)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/, path_match = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, default_ports = {'http': 80, 'https': 443, 'ftp': 21};
so why want that? using angular framework desktop air application. air applications can built using html/js, subsequently wrapped in air provides access filesystem , os. combination allows build multi-platform desktop web application angular. powerful stuff.
here problem air has custom address bar string looks app:/
rather http://
. has 1 slash instead of two. angular uses the address bar location route application, i.e. http://something.com/#/contactlist
means load contactlist
view , associated controller. knowledge of regex pretty (very) limited can't read patterns included above, guessing 1 slash instead of 2 or similar problem.
my aim adjust patterns app:/
valid pattern , hope uri segment making , associated actions still work.
see mozilla regular expressions doc: https://developer.mozilla.org/en-us/docs/web/javascript/guide/regular_expressions
what @shaunhusain explained in comment correct, except following:
\w
matches single alphanumeric character or underscore+
matches 1 or more (not 0 or 1) of previous character
therefore, \w+
matches word of length 1 or more characters.
you need modify regex have 1 slash after colon if want match app:/
.
Comments
Post a Comment