11/**
2- * @license AngularJS v1.0.0rc12
2+ * @license AngularJS v1.0.0
33 * (c) 2010-2012 Google, Inc. http://angularjs.org
44 * License: MIT
55 */
@@ -1247,11 +1247,11 @@ function setupModuleLoader(window) {
12471247 * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
12481248 */
12491249var version = {
1250- full : '1.0.0rc12 ' , // all of these placeholder strings will be replaced by rake's
1250+ full : '1.0.0 ' , // all of these placeholder strings will be replaced by rake's
12511251 major : 1 , // compile task
12521252 minor : 0 ,
12531253 dot : 0 ,
1254- codeName : 'regression-extermination '
1254+ codeName : 'temporal-domination '
12551255} ;
12561256
12571257
@@ -4827,6 +4827,10 @@ function encodePath(path) {
48274827 return segments . join ( '/' ) ;
48284828}
48294829
4830+ function stripHash ( url ) {
4831+ return url . split ( '#' ) [ 0 ] ;
4832+ }
4833+
48304834
48314835function matchUrl ( url , obj ) {
48324836 var match = URL_MATCH . exec ( url ) ;
@@ -4906,19 +4910,19 @@ function convertToHashbangUrl(url, basePath, hashPrefix) {
49064910 * @param {string } url HTML5 url
49074911 * @param {string } pathPrefix
49084912 */
4909- function LocationUrl ( url , pathPrefix ) {
4913+ function LocationUrl ( url , pathPrefix , appBaseUrl ) {
49104914 pathPrefix = pathPrefix || '' ;
49114915
49124916 /**
49134917 * Parse given html5 (regular) url string into properties
4914- * @param {string } url HTML5 url
4918+ * @param {string } newAbsoluteUrl HTML5 url
49154919 * @private
49164920 */
4917- this . $$parse = function ( url ) {
4918- var match = matchUrl ( url , this ) ;
4921+ this . $$parse = function ( newAbsoluteUrl ) {
4922+ var match = matchUrl ( newAbsoluteUrl , this ) ;
49194923
49204924 if ( match . path . indexOf ( pathPrefix ) !== 0 ) {
4921- throw Error ( 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !' ) ;
4925+ throw Error ( 'Invalid url "' + newAbsoluteUrl + '", missing path prefix "' + pathPrefix + '" !' ) ;
49224926 }
49234927
49244928 this . $$path = decodeURIComponent ( match . path . substr ( pathPrefix . length ) ) ;
@@ -4941,6 +4945,14 @@ function LocationUrl(url, pathPrefix) {
49414945 pathPrefix + this . $$url ;
49424946 } ;
49434947
4948+
4949+ this . $$rewriteAppUrl = function ( absoluteLinkUrl ) {
4950+ if ( absoluteLinkUrl . indexOf ( appBaseUrl ) == 0 ) {
4951+ return absoluteLinkUrl ;
4952+ }
4953+ }
4954+
4955+
49444956 this . $$parse ( url ) ;
49454957}
49464958
@@ -4953,7 +4965,7 @@ function LocationUrl(url, pathPrefix) {
49534965 * @param {string } url Legacy url
49544966 * @param {string } hashPrefix Prefix for hash part (containing path and search)
49554967 */
4956- function LocationHashbangUrl ( url , hashPrefix ) {
4968+ function LocationHashbangUrl ( url , hashPrefix , appBaseUrl ) {
49574969 var basePath ;
49584970
49594971 /**
@@ -4996,6 +5008,13 @@ function LocationHashbangUrl(url, hashPrefix) {
49965008 basePath + ( this . $$url ? '#' + hashPrefix + this . $$url : '' ) ;
49975009 } ;
49985010
5011+ this . $$rewriteAppUrl = function ( absoluteLinkUrl ) {
5012+ if ( absoluteLinkUrl . indexOf ( appBaseUrl ) == 0 ) {
5013+ return absoluteLinkUrl ;
5014+ }
5015+ }
5016+
5017+
49995018 this . $$parse ( url ) ;
50005019}
50015020
@@ -5184,6 +5203,19 @@ LocationUrl.prototype = {
51845203
51855204LocationHashbangUrl . prototype = inherit ( LocationUrl . prototype ) ;
51865205
5206+ function LocationHashbangInHtml5Url ( url , hashPrefix , appBaseUrl , baseExtra ) {
5207+ LocationHashbangUrl . apply ( this , arguments ) ;
5208+
5209+
5210+ this . $$rewriteAppUrl = function ( absoluteLinkUrl ) {
5211+ if ( absoluteLinkUrl . indexOf ( appBaseUrl ) == 0 ) {
5212+ return appBaseUrl + baseExtra + '#' + hashPrefix + absoluteLinkUrl . substr ( appBaseUrl . length ) ;
5213+ }
5214+ }
5215+ }
5216+
5217+ LocationHashbangInHtml5Url . prototype = inherit ( LocationHashbangUrl . prototype ) ;
5218+
51875219function locationGetter ( property ) {
51885220 return function ( ) {
51895221 return this [ property ] ;
@@ -5283,26 +5315,33 @@ function $LocationProvider(){
52835315 basePath ,
52845316 pathPrefix ,
52855317 initUrl = $browser . url ( ) ,
5286- absUrlPrefix ;
5318+ initUrlParts = matchUrl ( initUrl ) ,
5319+ appBaseUrl ;
52875320
52885321 if ( html5Mode ) {
52895322 basePath = $browser . baseHref ( ) || '/' ;
52905323 pathPrefix = pathPrefixFromBase ( basePath ) ;
5324+ appBaseUrl =
5325+ composeProtocolHostPort ( initUrlParts . protocol , initUrlParts . host , initUrlParts . port ) +
5326+ pathPrefix + '/' ;
5327+
52915328 if ( $sniffer . history ) {
52925329 $location = new LocationUrl (
52935330 convertToHtml5Url ( initUrl , basePath , hashPrefix ) ,
5294- pathPrefix ) ;
5331+ pathPrefix , appBaseUrl ) ;
52955332 } else {
5296- $location = new LocationHashbangUrl (
5333+ $location = new LocationHashbangInHtml5Url (
52975334 convertToHashbangUrl ( initUrl , basePath , hashPrefix ) ,
5298- hashPrefix ) ;
5335+ hashPrefix , appBaseUrl , basePath . substr ( pathPrefix . length + 1 ) ) ;
52995336 }
5300- // link rewriting
5301- absUrlPrefix = composeProtocolHostPort (
5302- $location . protocol ( ) , $location . host ( ) , $location . port ( ) ) + pathPrefix ;
53035337 } else {
5304- $location = new LocationHashbangUrl ( initUrl , hashPrefix ) ;
5305- absUrlPrefix = $location . absUrl ( ) . split ( '#' ) [ 0 ] ;
5338+ appBaseUrl =
5339+ composeProtocolHostPort ( initUrlParts . protocol , initUrlParts . host , initUrlParts . port ) +
5340+ ( initUrlParts . path || '' ) +
5341+ ( initUrlParts . search ? ( '?' + initUrlParts . search ) : '' ) +
5342+ '#' + hashPrefix + '/' ;
5343+
5344+ $location = new LocationHashbangUrl ( initUrl , hashPrefix , appBaseUrl ) ;
53065345 }
53075346
53085347 $rootElement . bind ( 'click' , function ( event ) {
@@ -5314,27 +5353,22 @@ function $LocationProvider(){
53145353 var elm = jqLite ( event . target ) ;
53155354
53165355 // traverse the DOM up to find first A tag
5317- while ( elm . length && lowercase ( elm [ 0 ] . nodeName ) !== 'a' ) {
5356+ while ( lowercase ( elm [ 0 ] . nodeName ) !== 'a' ) {
5357+ if ( elm [ 0 ] === $rootElement [ 0 ] ) return ;
53185358 elm = elm . parent ( ) ;
53195359 }
53205360
53215361 var absHref = elm . prop ( 'href' ) ,
5322- href ;
5362+ rewrittenUrl = $location . $$rewriteAppUrl ( absHref ) ;
53235363
5324- if ( ! absHref ||
5325- elm . attr ( 'target' ) ||
5326- absHref . indexOf ( absUrlPrefix ) !== 0 ) { // link to different domain or base path
5327- return ;
5364+ if ( absHref && ! elm . attr ( 'target' ) && rewrittenUrl ) {
5365+ // update location manually
5366+ $location . $$parse ( rewrittenUrl ) ;
5367+ $rootScope . $apply ( ) ;
5368+ event . preventDefault ( ) ;
5369+ // hack to work around FF6 bug 684208 when scenario runner clicks on links
5370+ window . angular [ 'ff-684208-preventDefault' ] = true ;
53285371 }
5329-
5330- // update location with href without the prefix
5331- href = absHref . substr ( absUrlPrefix . length ) ;
5332- if ( href . charAt ( 0 ) == '#' ) href = href . substr ( 1 ) ;
5333- $location . url ( href ) ;
5334- $rootScope . $apply ( ) ;
5335- event . preventDefault ( ) ;
5336- // hack to work around FF6 bug 684208 when scenario runner clicks on links
5337- window . angular [ 'ff-684208-preventDefault' ] = true ;
53385372 } ) ;
53395373
53405374
0 commit comments