diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..adfc452953 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,21 @@ +name: CodeQL + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + analyze: + runs-on: ubuntu-latest + permissions: + security-events: write + steps: + - uses: actions/checkout@v3 + - uses: github/codeql-action/init@v2 + with: + languages: javascript + - uses: github/codeql-action/analyze@v2 diff --git a/angular/src/providers/platform.ts b/angular/src/providers/platform.ts index f8d7d2c2fe..95a33a7a21 100644 --- a/angular/src/providers/platform.ts +++ b/angular/src/providers/platform.ts @@ -253,7 +253,7 @@ export class Platform { } const readQueryParam = (url: string, key: string) => { - key = key.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); + key = key.replace(/[[\]\\]/g, '\\$&'); const regex = new RegExp('[\\?&]' + key + '=([^]*)'); const results = regex.exec(url); return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null; diff --git a/angular/test/test-app/e2e/src/providers.spec.ts b/angular/test/test-app/e2e/src/providers.spec.ts index 7b14ad30d9..e373454e40 100644 --- a/angular/test/test-app/e2e/src/providers.spec.ts +++ b/angular/test/test-app/e2e/src/providers.spec.ts @@ -13,6 +13,7 @@ describe('Providers', () => { cy.get('#is-desktop').should('have.text', 'true'); cy.get('#is-mobile').should('have.text', 'false'); cy.get('#keyboard-height').should('have.text', '12345'); + cy.get('#query-params').should('have.text', 'firstParam: null, firstParam: null'); }); it('should detect testing mode', () => { @@ -20,5 +21,11 @@ describe('Providers', () => { cy.get('#is-testing').should('have.text', 'true'); }); + + it('should get query params', () => { + cy.visit('/providers?firstParam=abc&secondParam=true'); + + cy.get('#query-params').should('have.text', 'firstParam: abc, firstParam: true'); + }) }); diff --git a/angular/test/test-app/src/app/providers/providers.component.html b/angular/test/test-app/src/app/providers/providers.component.html index 140f6fab98..f198ba6518 100644 --- a/angular/test/test-app/src/app/providers/providers.component.html +++ b/angular/test/test-app/src/app/providers/providers.component.html @@ -33,4 +33,7 @@
keyboardHeight: {{keyboardHeight}}
++ queryParams: {{queryParams}} +
diff --git a/angular/test/test-app/src/app/providers/providers.component.ts b/angular/test/test-app/src/app/providers/providers.component.ts index a928b13a7c..b727ad30ee 100644 --- a/angular/test/test-app/src/app/providers/providers.component.ts +++ b/angular/test/test-app/src/app/providers/providers.component.ts @@ -20,6 +20,7 @@ export class ProvidersComponent { isDesktop: boolean = undefined; isMobile: boolean = undefined; keyboardHeight = 0; + queryParams = ''; constructor( actionSheetCtrl: ActionSheetController, @@ -64,6 +65,10 @@ export class ProvidersComponent { NgZone.assertInAngularZone(); this.isResized = true; }); + const firstQuery = platform.getQueryParam('firstParam'); + const secondQuery = platform.getQueryParam('secondParam'); + this.queryParams = `firstParam: ${firstQuery}, firstParam: ${secondQuery}`; + this.isDesktop = platform.is('desktop'); this.isMobile = platform.is('mobile');