First things first, I want to adjust the pattern that Angular uses to match against for URL routing. I have found the function and it is running the 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 would I want to do that? I am using angular as the framework for a desktop AIR application. AIR applications can be built using HTML/JS, which is subsequently wrapped in AIR which provides access to the filesystem and OS. So this combination essentially allows you to build a multi-platform desktop web application with angular. Powerful stuff.
Here is the problem AIR has a custom address bar string which looks like app:/
rather than http://
. So it has one slash instead of two. Angular uses the the address bar location to route the application, i.e. http://something.com/#/contactList
means load the contactList
view and its associated controller. My knowledge of regex is pretty (very) limited so I can't read the patterns I included above, but I am guessing that the one slash instead of two or something similar to that could be the problem.
My aim is to adjust the patterns so that app:/
would be a valid pattern and my hope is that the URI segment making and associated actions would still work.