diff --git a/core/src/utilities/helpers/routing-helpers.js b/core/src/utilities/helpers/routing-helpers.js index 49cb373271..c30d1912a3 100644 --- a/core/src/utilities/helpers/routing-helpers.js +++ b/core/src/utilities/helpers/routing-helpers.js @@ -1,13 +1,7 @@ // Helper methods for 'routing.js' file. They don't require any method from 'routing.js' but are required by them. // They are also rarely used directly from outside of 'routing.js' import { LuigiConfig, LuigiFeatureToggles, LuigiI18N, LuigiRouting } from '../../core-api'; -import { - AsyncHelpers, - EscapingHelpers, - EventListenerHelpers, - GenericHelpers, - IframeHelpers, -} from './'; +import { AsyncHelpers, EscapingHelpers, EventListenerHelpers, GenericHelpers, IframeHelpers } from './'; import { Routing } from '../../services/routing'; class RoutingHelpersClass { @@ -54,7 +48,7 @@ class RoutingHelpersClass { parseParams(paramsString) { if (!paramsString) return {}; const result = {}; - const viewParamString = paramsString; + const viewParamString = paramsString.replace(/\+/g, ' '); const pairs = viewParamString ? viewParamString.split('&') : null; if (pairs) { pairs.forEach(pairString => { diff --git a/core/test/core-api/routing.spec.js b/core/test/core-api/routing.spec.js index 27868e57fb..b986576084 100644 --- a/core/test/core-api/routing.spec.js +++ b/core/test/core-api/routing.spec.js @@ -168,6 +168,16 @@ describe('Luigi routing', function() { RoutingHelpers.modifySearchParams({ test: 'tets', luigi: 'rocks' }, searchParams, '~'); assert.equal(searchParams.toString(), '%7Emario=rocks&%7Etest=tets&%7Eluigi=rocks'); }); + it('modifySearchParams with space', () => { + const searchParams = new URLSearchParams('~mario=rocks'); + RoutingHelpers.modifySearchParams({ test: 'test abc' }, searchParams, '~'); + assert.equal(searchParams.toString(), '%7Emario=rocks&%7Etest=test+abc'); + }); + it('modifySearchParams with a plus sign', () => { + const searchParams = new URLSearchParams('~mario=rocks'); + RoutingHelpers.modifySearchParams({ test: 'test+abc' }, searchParams, '~'); + assert.equal(searchParams.toString(), '%7Emario=rocks&%7Etest=test%2Babc'); + }); }); describe('addNodeParams', () => { diff --git a/core/test/utilities/helpers/routing-helpers.spec.js b/core/test/utilities/helpers/routing-helpers.spec.js index 089e041577..79e63ad29b 100644 --- a/core/test/utilities/helpers/routing-helpers.spec.js +++ b/core/test/utilities/helpers/routing-helpers.spec.js @@ -353,7 +353,7 @@ describe('Routing-helpers', () => { const node = { context, externalLink: { url: 'https://someurl.com', sameWindow: false }, - label: "External link" + label: 'External link' }; it('get context from node', () => { assert.deepEqual(RoutingHelpers.getContext(node, undefined), context); @@ -457,9 +457,9 @@ describe('Routing-helpers', () => { }; sinon.stub(RoutingHelpers, 'getRouteLink'); sinon - .stub(LuigiConfig, 'getConfigValue') - .withArgs('routing.useHashRouting') - .returns(false); + .stub(LuigiConfig, 'getConfigValue') + .withArgs('routing.useHashRouting') + .returns(false); }); afterEach(() => { sinon.restore(); @@ -472,7 +472,7 @@ describe('Routing-helpers', () => { pathSegment: 'something-else' }; RoutingHelpers.getRouteLink.returns({ url }); - expect(RoutingHelpers.calculateNodeHref(node , {})).to.equal('https://luigi-project.io'); + expect(RoutingHelpers.calculateNodeHref(node, {})).to.equal('https://luigi-project.io'); }); }); describe('getNodeHref', () => { @@ -548,6 +548,14 @@ describe('Routing-helpers', () => { mockParams = ''; expect(RoutingHelpers.parseParams(mockParams)).to.deep.equal({}); }); + + it('return pairs of params with a space and a plus', () => { + mockParams = 'test=true+abc&foo=bar%2Babc'; + assert.deepEqual(RoutingHelpers.parseParams(mockParams), { + test: 'true abc', + foo: 'bar+abc' + }); + }); }); describe('findViewGroup', () => { diff --git a/test/e2e-test-application/src/app/app.module.ts b/test/e2e-test-application/src/app/app.module.ts index 112468e15a..b761acce22 100644 --- a/test/e2e-test-application/src/app/app.module.ts +++ b/test/e2e-test-application/src/app/app.module.ts @@ -62,10 +62,7 @@ import { ViewGroupComponent } from './project/view-group/view-group.component'; ViewGroupComponent ], imports: [BrowserModule, FormsModule, AppRoutingModule], - providers: [ - LuigiContextService, - LuigiAutoNavigationService - ], + providers: [LuigiContextService, LuigiAutoNavigationService], bootstrap: [AppComponent] }) export class AppModule {}