* LocationHashbangUrl represents url * This object is exposed as $location service when html5 history api is enabled but the browser * does not support it. * * @constructor * @param {string} appBase application base URL * @param {string} appBaseNoFile application base URL stripped of any filen
(appBase, appBaseNoFile, hashPrefix)
| 11949 | * @param {string} hashPrefix hashbang prefix |
| 11950 | */ |
| 11951 | function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) { |
| 11952 | this.$$html5 = true; |
| 11953 | LocationHashbangUrl.apply(this, arguments); |
| 11954 | |
| 11955 | this.$$parseLinkUrl = function(url, relHref) { |
| 11956 | if (relHref && relHref[0] === '#') { |
| 11957 | // special case for links to hash fragments: |
| 11958 | // keep the old url and only replace the hash fragment |
| 11959 | this.hash(relHref.slice(1)); |
| 11960 | return true; |
| 11961 | } |
| 11962 | |
| 11963 | var rewrittenUrl; |
| 11964 | var appUrl; |
| 11965 | |
| 11966 | if (appBase == stripHash(url)) { |
| 11967 | rewrittenUrl = url; |
| 11968 | } else if ((appUrl = beginsWith(appBaseNoFile, url))) { |
| 11969 | rewrittenUrl = appBase + hashPrefix + appUrl; |
| 11970 | } else if (appBaseNoFile === url + '/') { |
| 11971 | rewrittenUrl = appBaseNoFile; |
| 11972 | } |
| 11973 | if (rewrittenUrl) { |
| 11974 | this.$$parse(rewrittenUrl); |
| 11975 | } |
| 11976 | return !!rewrittenUrl; |
| 11977 | }; |
| 11978 | |
| 11979 | this.$$compose = function() { |
| 11980 | var search = toKeyValue(this.$$search), |
| 11981 | hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; |
| 11982 | |
| 11983 | this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; |
| 11984 | // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#' |
| 11985 | this.$$absUrl = appBase + hashPrefix + this.$$url; |
| 11986 | }; |
| 11987 | |
| 11988 | } |
| 11989 | |
| 11990 | |
| 11991 | var locationPrototype = { |
nothing calls this directly
no test coverage detected