diff --git a/lib/core/src/lib/app-config/app-config.service.spec.ts b/lib/core/src/lib/app-config/app-config.service.spec.ts index a6b045da5fb..7ec1b98f959 100644 --- a/lib/core/src/lib/app-config/app-config.service.spec.ts +++ b/lib/core/src/lib/app-config/app-config.service.spec.ts @@ -198,4 +198,20 @@ describe('AppConfigService', () => { expect(fakeCallBack).toHaveBeenCalled(); }); + it('should replace all the configuration placeholders if the provided key is an object', () => { + appConfigService.config.objectKey = { + firstUrl: '{protocol}//{hostname}{:port}', + secondUrl: '{protocol}//{hostname}{:port}', + thirdUrl: '{protocol}//{hostname}{:port}' + }; + spyOn(appConfigService, 'getLocationHostname').and.returnValue('localhost'); + spyOn(appConfigService, 'getLocationPort').and.returnValue(':8080'); + spyOn(appConfigService, 'getLocationProtocol').and.returnValue('http:'); + + expect(appConfigService.get('objectKey').firstUrl).toEqual('http://localhost:8080'); + expect(appConfigService.get('objectKey').secondUrl).toEqual('http://localhost:8080'); + expect(appConfigService.get('objectKey').thirdUrl).toEqual('http://localhost:8080'); + }); + + }); diff --git a/lib/core/src/lib/app-config/app-config.service.ts b/lib/core/src/lib/app-config/app-config.service.ts index 314522a5add..549639b32b1 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -123,9 +123,9 @@ export class AppConfigService { } if (typeof result === 'object') { - result = JSON.parse(JSON.stringify(result).replace('{hostname}', this.getLocationHostname())); - result = JSON.parse(JSON.stringify(result).replace('{:port}', this.getLocationPort(':'))); - result = JSON.parse(JSON.stringify(result).replace('{protocol}', this.getLocationProtocol())); + result = JSON.parse(JSON.stringify(result).replace(/{hostname}/g, this.getLocationHostname())); + result = JSON.parse(JSON.stringify(result).replace(/{:port}/g, this.getLocationPort(':'))); + result = JSON.parse(JSON.stringify(result).replace(/{protocol}/g, this.getLocationProtocol())); } if (result === undefined) { @@ -255,6 +255,7 @@ export class AppConfigService { const silentLogin = config['silentLogin'] === true || config['silentLogin'] === 'true'; const codeFlow = config['codeFlow'] === true || config['codeFlow'] === 'true'; + console.log('config: ', config); return { ...(config as OauthConfigModel), implicitFlow,