@@ -87,13 +87,13 @@ function serverBase(url) {
87
87
88
88
89
89
/**
90
- * LocationHtml5Url represents an url
90
+ * LocationHtml5Url represents a URL
91
91
* This object is exposed as $location service when HTML5 mode is enabled and supported
92
92
*
93
93
* @constructor
94
94
* @param {string } appBase application base URL
95
95
* @param {string } appBaseNoFile application base URL stripped of any filename
96
- * @param {string } basePrefix url path prefix
96
+ * @param {string } basePrefix URL path prefix
97
97
*/
98
98
function LocationHtml5Url ( appBase , appBaseNoFile , basePrefix ) {
99
99
this . $$html5 = true ;
@@ -102,8 +102,8 @@ function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
102
102
103
103
104
104
/**
105
- * Parse given html5 (regular) url string into properties
106
- * @param {string } url HTML5 url
105
+ * Parse given HTML5 (regular) URL string into properties
106
+ * @param {string } url HTML5 URL
107
107
* @private
108
108
*/
109
109
this . $$parse = function ( url ) {
@@ -165,7 +165,7 @@ function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
165
165
166
166
167
167
/**
168
- * LocationHashbangUrl represents url
168
+ * LocationHashbangUrl represents URL
169
169
* This object is exposed as $location service when developer doesn't opt into html5 mode.
170
170
* It also serves as the base class for html5 mode fallback on legacy browsers.
171
171
*
@@ -180,8 +180,8 @@ function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
180
180
181
181
182
182
/**
183
- * Parse given hashbang url into properties
184
- * @param {string } url Hashbang url
183
+ * Parse given hashbang URL into properties
184
+ * @param {string } url Hashbang URL
185
185
* @private
186
186
*/
187
187
this . $$parse = function ( url ) {
@@ -190,7 +190,7 @@ function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
190
190
191
191
if ( ! isUndefined ( withoutBaseUrl ) && withoutBaseUrl . charAt ( 0 ) === '#' ) {
192
192
193
- // The rest of the url starts with a hash so we have
193
+ // The rest of the URL starts with a hash so we have
194
194
// got either a hashbang path or a plain hash fragment
195
195
withoutHashUrl = stripBaseUrl ( hashPrefix , withoutBaseUrl ) ;
196
196
if ( isUndefined ( withoutHashUrl ) ) {
@@ -255,7 +255,7 @@ function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
255
255
} ;
256
256
257
257
/**
258
- * Compose hashbang url and update `absUrl` property
258
+ * Compose hashbang URL and update `absUrl` property
259
259
* @private
260
260
*/
261
261
this . $$compose = function ( ) {
@@ -277,7 +277,7 @@ function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
277
277
278
278
279
279
/**
280
- * LocationHashbangUrl represents url
280
+ * LocationHashbangUrl represents URL
281
281
* This object is exposed as $location service when html5 history api is enabled but the browser
282
282
* does not support it.
283
283
*
@@ -329,7 +329,7 @@ function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
329
329
var locationPrototype = {
330
330
331
331
/**
332
- * Ensure absolute url is initialized.
332
+ * Ensure absolute URL is initialized.
333
333
* @private
334
334
*/
335
335
$$absUrl :'' ,
@@ -353,17 +353,17 @@ var locationPrototype = {
353
353
* @description
354
354
* This method is getter only.
355
355
*
356
- * Return full url representation with all segments encoded according to rules specified in
356
+ * Return full URL representation with all segments encoded according to rules specified in
357
357
* [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt).
358
358
*
359
359
*
360
360
* ```js
361
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
361
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
362
362
* var absUrl = $location.absUrl();
363
363
* // => "http://example.com/#/some/path?foo=bar&baz=xoxo"
364
364
* ```
365
365
*
366
- * @return {string } full url
366
+ * @return {string } full URL
367
367
*/
368
368
absUrl : locationGetter ( '$$absUrl' ) ,
369
369
@@ -374,18 +374,18 @@ var locationPrototype = {
374
374
* @description
375
375
* This method is getter / setter.
376
376
*
377
- * Return url (e.g. `/path?a=b#hash`) when called without any parameter.
377
+ * Return URL (e.g. `/path?a=b#hash`) when called without any parameter.
378
378
*
379
379
* Change path, search and hash, when called with parameter and return `$location`.
380
380
*
381
381
*
382
382
* ```js
383
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
383
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
384
384
* var url = $location.url();
385
385
* // => "/some/path?foo=bar&baz=xoxo"
386
386
* ```
387
387
*
388
- * @param {string= } url New url without base prefix (e.g. `/path?a=b#hash`)
388
+ * @param {string= } url New URL without base prefix (e.g. `/path?a=b#hash`)
389
389
* @return {string } url
390
390
*/
391
391
url : function ( url ) {
@@ -408,16 +408,16 @@ var locationPrototype = {
408
408
* @description
409
409
* This method is getter only.
410
410
*
411
- * Return protocol of current url .
411
+ * Return protocol of current URL .
412
412
*
413
413
*
414
414
* ```js
415
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
415
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
416
416
* var protocol = $location.protocol();
417
417
* // => "http"
418
418
* ```
419
419
*
420
- * @return {string } protocol of current url
420
+ * @return {string } protocol of current URL
421
421
*/
422
422
protocol : locationGetter ( '$$protocol' ) ,
423
423
@@ -428,24 +428,24 @@ var locationPrototype = {
428
428
* @description
429
429
* This method is getter only.
430
430
*
431
- * Return host of current url .
431
+ * Return host of current URL .
432
432
*
433
433
* Note: compared to the non-angular version `location.host` which returns `hostname:port`, this returns the `hostname` portion only.
434
434
*
435
435
*
436
436
* ```js
437
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
437
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
438
438
* var host = $location.host();
439
439
* // => "example.com"
440
440
*
441
- * // given url http://user:password@example .com:8080/#/some/path?foo=bar&baz=xoxo
441
+ * // given URL http://user:password@example .com:8080/#/some/path?foo=bar&baz=xoxo
442
442
* host = $location.host();
443
443
* // => "example.com"
444
444
* host = location.host;
445
445
* // => "example.com:8080"
446
446
* ```
447
447
*
448
- * @return {string } host of current url .
448
+ * @return {string } host of current URL .
449
449
*/
450
450
host : locationGetter ( '$$host' ) ,
451
451
@@ -456,11 +456,11 @@ var locationPrototype = {
456
456
* @description
457
457
* This method is getter only.
458
458
*
459
- * Return port of current url .
459
+ * Return port of current URL .
460
460
*
461
461
*
462
462
* ```js
463
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
463
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
464
464
* var port = $location.port();
465
465
* // => 80
466
466
* ```
@@ -476,7 +476,7 @@ var locationPrototype = {
476
476
* @description
477
477
* This method is getter / setter.
478
478
*
479
- * Return path of current url when called without any parameter.
479
+ * Return path of current URL when called without any parameter.
480
480
*
481
481
* Change path when called with parameter and return `$location`.
482
482
*
@@ -485,7 +485,7 @@ var locationPrototype = {
485
485
*
486
486
*
487
487
* ```js
488
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
488
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
489
489
* var path = $location.path();
490
490
* // => "/some/path"
491
491
* ```
@@ -505,13 +505,13 @@ var locationPrototype = {
505
505
* @description
506
506
* This method is getter / setter.
507
507
*
508
- * Return search part (as object) of current url when called without any parameter.
508
+ * Return search part (as object) of current URL when called without any parameter.
509
509
*
510
510
* Change search part when called with parameter and return `$location`.
511
511
*
512
512
*
513
513
* ```js
514
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo
514
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
515
515
* var searchObject = $location.search();
516
516
* // => {foo: 'bar', baz: 'xoxo'}
517
517
*
@@ -527,7 +527,7 @@ var locationPrototype = {
527
527
* of `$location` to the specified value.
528
528
*
529
529
* If the argument is a hash object containing an array of values, these values will be encoded
530
- * as duplicate search parameters in the url .
530
+ * as duplicate search parameters in the URL .
531
531
*
532
532
* @param {(string|Number|Array<string>|boolean)= } paramValue If `search` is a string or number, then `paramValue`
533
533
* will override only a single search property.
@@ -589,7 +589,7 @@ var locationPrototype = {
589
589
*
590
590
*
591
591
* ```js
592
- * // given url http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue
592
+ * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue
593
593
* var hash = $location.hash();
594
594
* // => "hashValue"
595
595
* ```
@@ -750,8 +750,12 @@ function $LocationProvider() {
750
750
* whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are
751
751
* true, and a base tag is not present, an error will be thrown when `$location` is injected.
752
752
* See the {@link guide/$location $location guide for more information}
753
- * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled,
754
- * enables/disables url rewriting for relative links.
753
+ * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled,
754
+ * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will
755
+ * only happen on links with an attribute that matches the given string. For example, if set
756
+ * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links.
757
+ * Note that [attribute name normalization](guide/directive#normalization) does not apply
758
+ * here, so `'internalLink'` will **not** match `'internal-link'`.
755
759
*
756
760
* @returns {Object } html5Mode object if used as getter or itself (chaining) if used as setter
757
761
*/
@@ -769,7 +773,7 @@ function $LocationProvider() {
769
773
html5Mode . requireBase = mode . requireBase ;
770
774
}
771
775
772
- if ( isBoolean ( mode . rewriteLinks ) ) {
776
+ if ( isBoolean ( mode . rewriteLinks ) || isString ( mode . rewriteLinks ) ) {
773
777
html5Mode . rewriteLinks = mode . rewriteLinks ;
774
778
}
775
779
@@ -866,10 +870,11 @@ function $LocationProvider() {
866
870
}
867
871
868
872
$rootElement . on ( 'click' , function ( event ) {
873
+ var rewriteLinks = html5Mode . rewriteLinks ;
869
874
// TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)
870
875
// currently we open nice url link and redirect then
871
876
872
- if ( ! html5Mode . rewriteLinks || event . ctrlKey || event . metaKey || event . shiftKey || event . which === 2 || event . button === 2 ) return ;
877
+ if ( ! rewriteLinks || event . ctrlKey || event . metaKey || event . shiftKey || event . which === 2 || event . button === 2 ) return ;
873
878
874
879
var elm = jqLite ( event . target ) ;
875
880
@@ -879,6 +884,8 @@ function $LocationProvider() {
879
884
if ( elm [ 0 ] === $rootElement [ 0 ] || ! ( elm = elm . parent ( ) ) [ 0 ] ) return ;
880
885
}
881
886
887
+ if ( isString ( rewriteLinks ) && isUndefined ( elm . attr ( rewriteLinks ) ) ) return ;
888
+
882
889
var absHref = elm . prop ( 'href' ) ;
883
890
// get the actual href attribute - see
884
891
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
0 commit comments