diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..3b08b03 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,48 @@ +name: "CodeQL" + +on: + push: + branches: [ master, develop, develop-* ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master, develop, develop-* ] + schedule: + - cron: '15 2 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Install modules + run: npm i + + - name: Lint + run: npm run lint:check + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 \ No newline at end of file diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 0000000..e2af089 --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,22 @@ +name: "npm" + +on: + push: + tags: + - "*" + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm i + - run: npm run lint + - run: CI=false npm run build + - uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} + check-version: true \ No newline at end of file diff --git a/package.json b/package.json index 24279d8..b3159ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aesirx-analytics", - "version": "1.0.0-alpha", + "version": "1.0.0-alpha.5", "license": "GPL-3.0-only", "author": "AesirX", "repository": "https://gitlab.redweb.dk/aesirx/analytics", diff --git a/src/analytics.js b/src/analytics.js index 82e9852..769dc2c 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -100,12 +100,13 @@ const replaceUrl = () => { }; const getParameterByName = (name, url = window.location.href) => { - name = name.replace(/[[\]]/g, '\\$&'); - var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, ' ')); + if (url) { + let params = new URL(url); + if (params.origin === window.location.origin) { + return params.searchParams.get(name); + } + } + return; }; AesirAnalytics();