diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..08f6bc6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + push: + branches: [main, master] + pull_request: + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: 'Version to publish (e.g., 1.0.0)' + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 8.x + - run: yarn install + - run: yarn build + + publish: + if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 8.x + - run: npm config set registry ${{ secrets.NPM_REGISTRY_URL }} + - run: yarn install + - name: Set version + if: github.event_name == 'workflow_dispatch' + run: npm version ${{ github.event.inputs.version }} --no-git-tag-version + - run: yarn build + - run: yarn publish --non-interactive + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/src/fns.js b/src/fns.js index fd07552..680c820 100644 --- a/src/fns.js +++ b/src/fns.js @@ -36,8 +36,13 @@ function extractQueryParams(path) { * @return {String} */ function extractPath(base, canonicalPath) { - let path = canonicalPath?.replace(base, '') || '/' - let qsIndex = path.indexOf('?') + let path = '/'; + + if (canonicalPath != null && typeof canonicalPath === 'string') { + path = canonicalPath.replace(base, '') || '/'; + } + + let qsIndex = path.indexOf('?'); return (qsIndex > -1) ? path.slice(0, qsIndex) : path }