ci: add CodeQL workflow (#25443)

Co-authored-by: Liam DeBeasi <liamdebeasi@icloud.com>
This commit is contained in:
Lars Mikkelsen
2022-06-17 15:54:16 -04:00
committed by GitHub
parent 7483d9143a
commit 897bd4a8d0
5 changed files with 37 additions and 1 deletions

21
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -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

View File

@ -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;

View File

@ -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');
})
});

View File

@ -33,4 +33,7 @@
<p>
keyboardHeight: <span id="keyboard-height">{{keyboardHeight}}</span>
</p>
<p>
queryParams: <span id="query-params">{{queryParams}}</span>
</p>
</ion-content>

View File

@ -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');