This repository was archived by the owner on Jan 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -482,18 +482,18 @@ export default Mixin.create({
482
482
483
483
let namespace = options . namespace || get ( this , 'namespace' ) ;
484
484
if ( namespace ) {
485
- // If the URL has already been constructed (presumably, by Ember Data), then we should just leave it alone
486
- const hasNamespaceRegex = new RegExp ( `^(/)?${ stripSlashes ( namespace ) } /` ) ;
487
- if ( hasNamespaceRegex . test ( url ) ) {
488
- return url ;
489
- }
490
485
// If host is given then we need to strip leading slash too( as it will be added through join)
491
486
if ( host ) {
492
487
namespace = stripSlashes ( namespace ) ;
493
488
} else if ( endsWithSlash ( namespace ) ) {
494
489
namespace = removeTrailingSlash ( namespace ) ;
495
490
}
496
- urlParts . push ( namespace ) ;
491
+
492
+ // If the URL has already been constructed (presumably, by Ember Data), then we should just leave it alone
493
+ const hasNamespaceRegex = new RegExp ( `^(/)?${ stripSlashes ( namespace ) } /` ) ;
494
+ if ( ! hasNamespaceRegex . test ( url ) ) {
495
+ urlParts . push ( namespace ) ;
496
+ }
497
497
}
498
498
499
499
// *Only* remove a leading slash when there is host or namespace -- we need to maintain a trailing slash for
Original file line number Diff line number Diff line change @@ -227,6 +227,20 @@ describe('Unit | Mixin | ajax request', function() {
227
227
) ;
228
228
} ) ;
229
229
230
+ it ( 'is set on the url containing namespace' , function ( ) {
231
+ const RequestWithHostAndNamespace = AjaxRequest . extend ( {
232
+ host : 'https://discuss.emberjs.com' ,
233
+ namespace : '/api/v1'
234
+ } ) ;
235
+ const service = new RequestWithHostAndNamespace ( ) ;
236
+ const url = '/api/v1/users/me' ;
237
+ const ajaxoptions = service . options ( url ) ;
238
+
239
+ expect ( ajaxoptions . url ) . to . equal (
240
+ 'https://discuss.emberjs.com/api/v1/users/me'
241
+ ) ;
242
+ } ) ;
243
+
230
244
it ( 'is set with the host address as `//` and url not starting with `/`' , function ( ) {
231
245
const RequestWithHostAndNamespace = AjaxRequest . extend ( {
232
246
host : '//'
You can’t perform that action at this time.
0 commit comments