@@ -348,6 +348,7 @@ function shallowClearAndCopy(src, dst) {
348
348
*/
349
349
angular . module ( 'ngResource' , [ 'ng' ] ) .
350
350
provider ( '$resource' , function ( ) {
351
+ var PROTOCOL_AND_DOMAIN_REGEX = / ^ h t t p s ? : \/ \/ [ ^ \/ ] * / ;
351
352
var provider = this ;
352
353
353
354
this . defaults = {
@@ -422,7 +423,8 @@ angular.module('ngResource', ['ng']).
422
423
var self = this ,
423
424
url = actionUrl || self . template ,
424
425
val ,
425
- encodedVal ;
426
+ encodedVal ,
427
+ protocolAndDomain = '' ;
426
428
427
429
var urlParams = self . urlParams = { } ;
428
430
forEach ( url . split ( / \W / ) , function ( param ) {
@@ -435,6 +437,10 @@ angular.module('ngResource', ['ng']).
435
437
}
436
438
} ) ;
437
439
url = url . replace ( / \\ : / g, ':' ) ;
440
+ url = url . replace ( PROTOCOL_AND_DOMAIN_REGEX , function ( match ) {
441
+ protocolAndDomain = match ;
442
+ return '' ;
443
+ } ) ;
438
444
439
445
params = params || { } ;
440
446
forEach ( self . urlParams , function ( _ , urlParam ) {
@@ -465,7 +471,7 @@ angular.module('ngResource', ['ng']).
465
471
// E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x`
466
472
url = url . replace ( / \/ \. (? = \w + ( $ | \? ) ) / , '.' ) ;
467
473
// replace escaped `/\.` with `/.`
468
- config . url = url . replace ( / \/ \\ \. / , '/.' ) ;
474
+ config . url = protocolAndDomain + url . replace ( / \/ \\ \. / , '/.' ) ;
469
475
470
476
471
477
// set params - delegate param encoding to $http
0 commit comments