@ez1219/sanitize-url 7.1.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cz-config.js +72 -0
- package/.eslintignore +2 -0
- package/.eslintrc +6 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report_form.yml +47 -0
- package/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/.github/ISSUE_TEMPLATE/feature_request_form.yml +30 -0
- package/.github/dependabot.yml +16 -0
- package/.github/pull_request_template.md +17 -0
- package/.github/workflows/ci.yml +30 -0
- package/.github/workflows/enforce-conventional-pr-title.yml +39 -0
- package/.github/workflows/publish.yml +65 -0
- package/.github/workflows/security.yml +22 -0
- package/.github/workflows/stale-cleanup.yml +22 -0
- package/.husky/commit-msg +2 -0
- package/.nvmrc +1 -0
- package/.prettierignore +3 -0
- package/CHANGELOG.md +155 -0
- package/CONTRIBUTING.md +79 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/SECURITY.md +41 -0
- package/commitlint.config.js +70 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +88 -0
- package/package.json +56 -0
- package/src/__tests__/index.test.ts +299 -0
- package/src/constants.ts +10 -0
- package/src/index.ts +114 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +17 -0
package/.cz-config.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
types: [
|
|
3
|
+
{ value: "feat", name: "feat: A new feature" },
|
|
4
|
+
{ value: "fix", name: "fix: A bug fix" },
|
|
5
|
+
{
|
|
6
|
+
value: "review",
|
|
7
|
+
name: "review: Commits added during the review process",
|
|
8
|
+
},
|
|
9
|
+
{ value: "docs", name: "docs: Documentation only changes" },
|
|
10
|
+
{
|
|
11
|
+
value: "style",
|
|
12
|
+
name: "style: Changes that do not affect the meaning of the code (formatting, semicolons)",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: "refactor",
|
|
16
|
+
name: "refactor: A code change that neither fixes a bug nor adds a feature",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "perf",
|
|
20
|
+
name: "perf: A code change that improves performance",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "test",
|
|
24
|
+
name: "test: Adding missing tests or correcting existing tests",
|
|
25
|
+
},
|
|
26
|
+
{ value: "build", name: "build: Build system changes" },
|
|
27
|
+
{
|
|
28
|
+
value: "dx",
|
|
29
|
+
name: "dx: Changes that affect the development cycle",
|
|
30
|
+
},
|
|
31
|
+
{ value: "ci", name: "ci: CI configuration changes" },
|
|
32
|
+
{
|
|
33
|
+
value: "chore",
|
|
34
|
+
name: "chore: Other maintenance, including dependency updates",
|
|
35
|
+
},
|
|
36
|
+
{ value: "revert", name: "revert: Revert a commit" },
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
scopes: [
|
|
40
|
+
{ name: "american-express" },
|
|
41
|
+
{ name: "apple-pay" },
|
|
42
|
+
{ name: "client" },
|
|
43
|
+
{ name: "data-collector" },
|
|
44
|
+
{ name: "fastlane" },
|
|
45
|
+
{ name: "google-payment" },
|
|
46
|
+
{ name: "hosted-fields" },
|
|
47
|
+
{ name: "instant-verification" },
|
|
48
|
+
{ name: "local-payment" },
|
|
49
|
+
{ name: "payment-ready" },
|
|
50
|
+
{ name: "payment-request" },
|
|
51
|
+
{ name: "paypal-checkout" },
|
|
52
|
+
{ name: "paypal-checkout-v6" },
|
|
53
|
+
{ name: "sepa" },
|
|
54
|
+
{ name: "three-d-secure" },
|
|
55
|
+
{ name: "us-bank-account" },
|
|
56
|
+
{ name: "vault-manager" },
|
|
57
|
+
{ name: "venmo" },
|
|
58
|
+
{ name: "deps" },
|
|
59
|
+
{ name: "other" },
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
// When type is "review", skip the scope prompt entirely
|
|
63
|
+
scopeOverrides: {
|
|
64
|
+
review: [],
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// Skip questions you don't need
|
|
68
|
+
skipQuestions: ["footer"],
|
|
69
|
+
|
|
70
|
+
// Limit subject length
|
|
71
|
+
subjectLimit: 85,
|
|
72
|
+
};
|
package/.eslintignore
ADDED
package/.eslintrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @ez1219
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: File a bug report.
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
projects: []
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thanks for taking the time to fill out this bug report!
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: what-happened
|
|
13
|
+
attributes:
|
|
14
|
+
label: What happened?
|
|
15
|
+
description: Detail the bad behavior and the steps required to duplicate it
|
|
16
|
+
placeholder: Tell us what you see!
|
|
17
|
+
value: "A bug happened!"
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: expected-behavior
|
|
22
|
+
attributes:
|
|
23
|
+
label: What did you expect to happen?
|
|
24
|
+
description: What did you expect to happen when performing the action?
|
|
25
|
+
placeholder: Expected behavior
|
|
26
|
+
value: "Expected behavior"
|
|
27
|
+
validations:
|
|
28
|
+
required: true
|
|
29
|
+
- type: input
|
|
30
|
+
id: version
|
|
31
|
+
attributes:
|
|
32
|
+
label: Version
|
|
33
|
+
description: What version of this library are you running?
|
|
34
|
+
placeholder: "v0.0.0"
|
|
35
|
+
value:
|
|
36
|
+
validations:
|
|
37
|
+
required: true
|
|
38
|
+
- type: textarea
|
|
39
|
+
id: browsers
|
|
40
|
+
attributes:
|
|
41
|
+
label: What browsers are you seeing the problem on?
|
|
42
|
+
description: |
|
|
43
|
+
List browsers where you see the problem reported. For example:
|
|
44
|
+
* Mac OS 15.3.5, Chrome 130.0.1234.987
|
|
45
|
+
* Android 14, Firefox 133.0
|
|
46
|
+
* iPadOS 17.1, Safari
|
|
47
|
+
placeholder: "For each browser specify 1) operating system and version 2) browser name and version"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
blank_issues_enabled: true
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Request a new feature.
|
|
3
|
+
title: "[FR]: "
|
|
4
|
+
labels: ["feature", "request", "enhancement", "triage"]
|
|
5
|
+
projects: []
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thanks for taking the time to fill out this feature request!
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: feat-summary
|
|
13
|
+
attributes:
|
|
14
|
+
label: Feature Summary
|
|
15
|
+
description: In a few sentences or less, provide a concise description of the feature being requested.
|
|
16
|
+
placeholder: "New feature that does ___; it can be used when ..."
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: detailed-description
|
|
21
|
+
attributes:
|
|
22
|
+
label: Detailed description of new feature.
|
|
23
|
+
description: |
|
|
24
|
+
Please provide a detailed description of proposed feature.
|
|
25
|
+
- What problem would this new feature solve?
|
|
26
|
+
- How will this change affect users?
|
|
27
|
+
- Is it a modification to existing functionality? Are you requesting a new/modified function input or output? Please provide an example of what the change might look like?
|
|
28
|
+
placeholder: "New feature details."
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "npm"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
open-pull-requests-limit: 3
|
|
8
|
+
allow:
|
|
9
|
+
- dependency-type: "development"
|
|
10
|
+
update-types:
|
|
11
|
+
- "version-update:semver-minor"
|
|
12
|
+
groups:
|
|
13
|
+
security-updates:
|
|
14
|
+
applies-to: security-updates
|
|
15
|
+
patterns:
|
|
16
|
+
- "*"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Summary of changes
|
|
2
|
+
|
|
3
|
+
-
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] Added a changelog entry
|
|
8
|
+
- [ ] Relevant test coverage
|
|
9
|
+
- [ ] Tested and confirmed flows affected by this change are functioning as expected
|
|
10
|
+
|
|
11
|
+
## Authors
|
|
12
|
+
|
|
13
|
+
> List GitHub usernames for everyone who contributed to this pull request.
|
|
14
|
+
|
|
15
|
+
### Reviewers
|
|
16
|
+
|
|
17
|
+
@ez1219
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: "CI"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- "*"
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
ci:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
node-version: [18, 20, 22, 24]
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: ${{ matrix.node-version }}
|
|
26
|
+
cache: "npm"
|
|
27
|
+
- run: npm ci
|
|
28
|
+
- run: npm test
|
|
29
|
+
- run: npm run build
|
|
30
|
+
- run: npm run lint
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: "PR Title Check"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- edited
|
|
8
|
+
- reopened
|
|
9
|
+
- synchronize
|
|
10
|
+
- labeled
|
|
11
|
+
- ready_for_review
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
pr-title-check:
|
|
15
|
+
name: "Validate PR title"
|
|
16
|
+
if: >-
|
|
17
|
+
github.actor != 'dependabot[bot]' &&
|
|
18
|
+
!contains(github.actor, '[bot]') &&
|
|
19
|
+
github.event.pull_request.draft == false
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
env:
|
|
22
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
23
|
+
steps:
|
|
24
|
+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50
|
|
25
|
+
with:
|
|
26
|
+
types: |
|
|
27
|
+
feat
|
|
28
|
+
fix
|
|
29
|
+
docs
|
|
30
|
+
style
|
|
31
|
+
refactor
|
|
32
|
+
perf
|
|
33
|
+
test
|
|
34
|
+
build
|
|
35
|
+
ci
|
|
36
|
+
chore
|
|
37
|
+
revert
|
|
38
|
+
requireScope: false
|
|
39
|
+
ignoreLabels: ignore-semantic-pull-request
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: "Publish to npm"
|
|
2
|
+
run-name: Deploy ${{ github.repository }} to npmjs by @${{ github.actor }}
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
version_type:
|
|
10
|
+
description: "Version bump type (major, minor, patch)"
|
|
11
|
+
required: false
|
|
12
|
+
type: choice
|
|
13
|
+
default: "none"
|
|
14
|
+
options:
|
|
15
|
+
- none
|
|
16
|
+
- patch
|
|
17
|
+
- minor
|
|
18
|
+
- major
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
publish:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: write
|
|
25
|
+
id-token: write
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
with:
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- uses: actions/setup-node@v4
|
|
32
|
+
with:
|
|
33
|
+
node-version: 20
|
|
34
|
+
cache: "npm"
|
|
35
|
+
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: npm ci
|
|
38
|
+
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: npm test
|
|
41
|
+
|
|
42
|
+
- name: Bump version & create GitHub Release
|
|
43
|
+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version_type != 'none' }}
|
|
44
|
+
env:
|
|
45
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
run: |
|
|
47
|
+
git config user.name "github-actions[bot]"
|
|
48
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
49
|
+
npm version ${{ inputs.version_type }} -m "chore(release): %s [skip ci]"
|
|
50
|
+
git push
|
|
51
|
+
git push --tags
|
|
52
|
+
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
53
|
+
gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --generate-notes
|
|
54
|
+
|
|
55
|
+
- name: Build package
|
|
56
|
+
run: npm run build
|
|
57
|
+
|
|
58
|
+
- name: Publish to npm (with Provenance / OIDC)
|
|
59
|
+
run: |
|
|
60
|
+
if [ -n "$NODE_AUTH_TOKEN" ]; then
|
|
61
|
+
npm config set //registry.npmjs.org/:_authToken "$NODE_AUTH_TOKEN"
|
|
62
|
+
fi
|
|
63
|
+
npm publish --access public --provenance
|
|
64
|
+
env:
|
|
65
|
+
NODE_AUTH_TOKEN: ${{ coalesce(secrets.NPM_TOKEN, secrets.NODE_AUTH_TOKEN) }}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Security
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: read
|
|
5
|
+
security-events: write
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [main]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main]
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
codeql:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: github/codeql-action/init@v3
|
|
20
|
+
with:
|
|
21
|
+
languages: javascript-typescript
|
|
22
|
+
- uses: github/codeql-action/analyze@v3
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: "Stale Cleanup"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
# Runs at midnight UTC every Wednesday
|
|
6
|
+
- cron: "0 0 * * 3"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
stale:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/stale@v9
|
|
18
|
+
with:
|
|
19
|
+
stale-issue-message: "This issue is stale because it has been open for 60 days with no activity."
|
|
20
|
+
stale-pr-message: "This PR is stale because it has been open for 60 days with no activity."
|
|
21
|
+
days-before-stale: 60
|
|
22
|
+
days-before-close: 7
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v24
|
package/.prettierignore
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## UNRELEASED
|
|
4
|
+
|
|
5
|
+
- feat(deps): Add [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to the repo
|
|
6
|
+
|
|
7
|
+
## 7.1.2
|
|
8
|
+
|
|
9
|
+
- Update dependencies
|
|
10
|
+
- @types/jest to 30.0.0
|
|
11
|
+
- @vitest/coverage-v8 to 4.0.16
|
|
12
|
+
- chai to 6.2.2
|
|
13
|
+
- eslint-plugin-prettier to 5.5.4
|
|
14
|
+
- happy-dom to 20.0.11
|
|
15
|
+
- prettier to 3.7.4
|
|
16
|
+
- typescript to 5.9.3
|
|
17
|
+
- vitest to 4.0.16
|
|
18
|
+
- Update Node to v24
|
|
19
|
+
- Add @types/node 24.0.0
|
|
20
|
+
|
|
21
|
+
## 7.1.1
|
|
22
|
+
|
|
23
|
+
- DevDependency Changes
|
|
24
|
+
- happy-dom to 15.11.6
|
|
25
|
+
|
|
26
|
+
- Update (sub-)dependencies
|
|
27
|
+
- cross-spawn to 7.0.6
|
|
28
|
+
- micromatch to 4.0.8
|
|
29
|
+
- vite to 4.5.5
|
|
30
|
+
|
|
31
|
+
## 7.1.0
|
|
32
|
+
|
|
33
|
+
- Updated to handle back-slashes
|
|
34
|
+
|
|
35
|
+
## 7.0.4
|
|
36
|
+
|
|
37
|
+
- Updates get-func-name to 2.0.2
|
|
38
|
+
|
|
39
|
+
## 7.0.3
|
|
40
|
+
|
|
41
|
+
- Dependencies
|
|
42
|
+
- Update braces to 3.0.3
|
|
43
|
+
|
|
44
|
+
## 7.0.2
|
|
45
|
+
|
|
46
|
+
- Improve sanitization of whitespace escapes
|
|
47
|
+
|
|
48
|
+
## 7.0.1
|
|
49
|
+
|
|
50
|
+
- Improve sanitization of HTML entities
|
|
51
|
+
|
|
52
|
+
## 7.0.0
|
|
53
|
+
|
|
54
|
+
- Move constant declarations from index file to `constants.ts` file
|
|
55
|
+
- Update to node v18
|
|
56
|
+
|
|
57
|
+
- Dev Dependency Updates
|
|
58
|
+
- Update to TypeScript 5
|
|
59
|
+
- Other minor dependency updates
|
|
60
|
+
|
|
61
|
+
## 6.0.4
|
|
62
|
+
|
|
63
|
+
- Add additional null byte sanitization prior to html decoding (#48)
|
|
64
|
+
|
|
65
|
+
## 6.0.3
|
|
66
|
+
|
|
67
|
+
- Add null check to beginning of `sanitizeUrl` function ([#54](https://github.com/braintree/sanitize-url/issues/54))
|
|
68
|
+
|
|
69
|
+
## 6.0.2
|
|
70
|
+
|
|
71
|
+
- Fix issue where urls in the form `https://example.com

/something` were not properly sanitized
|
|
72
|
+
|
|
73
|
+
## 6.0.1
|
|
74
|
+
|
|
75
|
+
- Fix issue where urls in the form `javascript:alert('xss');` were not properly sanitized
|
|
76
|
+
- Fix issue where urls in the form `javasc	ript:alert('XSS');` were not properly sanitized
|
|
77
|
+
|
|
78
|
+
## 6.0.0
|
|
79
|
+
|
|
80
|
+
- BREAKING CHANGES
|
|
81
|
+
- Decode HTML characters automatically that would result in an XSS vulnerability when rendering links via a server rendered HTML file
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
// decodes to javacript:alert('XSS')
|
|
85
|
+
const vulnerableUrl =
|
|
86
|
+
"javascript:alert('XSS')";
|
|
87
|
+
|
|
88
|
+
sanitizeUrl(vulnerableUrl); // 'about:blank'
|
|
89
|
+
|
|
90
|
+
const okUrl = "https://example.com/" + vulnerableUrl;
|
|
91
|
+
|
|
92
|
+
// since the javascript bit is in the path instead of the protocol
|
|
93
|
+
// this is successfully sanitized
|
|
94
|
+
sanitizeUrl(okUrl); // 'https://example.com/javascript:alert('XSS');
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 5.0.2
|
|
98
|
+
|
|
99
|
+
- Fix issue where certain invisible white space characters were not being sanitized (#35)
|
|
100
|
+
|
|
101
|
+
## 5.0.1
|
|
102
|
+
|
|
103
|
+
- Fix issue where certain safe characters were being filtered out (#31 thanks @akirchmyer)
|
|
104
|
+
|
|
105
|
+
## 5.0.0
|
|
106
|
+
|
|
107
|
+
- BREAKING CHANGES
|
|
108
|
+
- Sanitize vbscript urls (thanks @vicnicius)
|
|
109
|
+
|
|
110
|
+
## 4.1.1
|
|
111
|
+
|
|
112
|
+
- Fixup path to type declaration (closes #25)
|
|
113
|
+
|
|
114
|
+
## 4.1.0
|
|
115
|
+
|
|
116
|
+
- Add typescript types
|
|
117
|
+
|
|
118
|
+
## 4.0.1
|
|
119
|
+
|
|
120
|
+
- Fix issue where urls with accented characters were incorrectly sanitized
|
|
121
|
+
|
|
122
|
+
## 4.0.0
|
|
123
|
+
|
|
124
|
+
- BREAKING CHANGES
|
|
125
|
+
- Protocol-less urls (ie: `www.example.com`) will be sanitised and passed on instead of sending out `about:blank` (Thanks @chawes13 #18)
|
|
126
|
+
|
|
127
|
+
## 3.1.0
|
|
128
|
+
|
|
129
|
+
- Trim whitespace from urls
|
|
130
|
+
|
|
131
|
+
## 3.0.0
|
|
132
|
+
|
|
133
|
+
- BREAKING CHANGES
|
|
134
|
+
- Replace blank strings with about:blank
|
|
135
|
+
- Replace null values with about:blank
|
|
136
|
+
|
|
137
|
+
## 2.1.0
|
|
138
|
+
|
|
139
|
+
- Allow relative urls to be sanitized
|
|
140
|
+
|
|
141
|
+
## 2.0.2
|
|
142
|
+
|
|
143
|
+
- Sanitize malicious URLs that begin with `\s`
|
|
144
|
+
|
|
145
|
+
## 2.0.1
|
|
146
|
+
|
|
147
|
+
- Sanitize malicious URLs that begin with %20
|
|
148
|
+
|
|
149
|
+
## 2.0.0
|
|
150
|
+
|
|
151
|
+
- sanitize data: urls
|
|
152
|
+
|
|
153
|
+
## 1.0.0
|
|
154
|
+
|
|
155
|
+
- sanitize javascript: urls
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for considering contributing to this project. Ways you can help:
|
|
4
|
+
|
|
5
|
+
- [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
|
|
6
|
+
- [Add an issue](https://github.com/ez1219/sanitize-url/issues)
|
|
7
|
+
|
|
8
|
+
## Development
|
|
9
|
+
|
|
10
|
+
Clone this repo, then install the project's dependencies:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Branch and PR Lifecycle
|
|
17
|
+
|
|
18
|
+
To keep the repository healthy, an automated workflow runs weekly:
|
|
19
|
+
|
|
20
|
+
- **Branches**: flagged after 21 days of inactivity; deleted 7 days later if
|
|
21
|
+
still inactive. To keep a branch, add new commits or remove the bot's comment.
|
|
22
|
+
- **Pull requests**: commented on after 14 days of inactivity; closed 7 days
|
|
23
|
+
later if still inactive. Closed PRs can be reopened at any time.
|
|
24
|
+
- **Issues**: commented on after 14 days of inactivity; closed 7 days later if
|
|
25
|
+
still inactive.
|
|
26
|
+
|
|
27
|
+
You can open a fresh PR or issue at any time if automated cleanup closes yours.
|
|
28
|
+
|
|
29
|
+
## Tests
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
npm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Test Stability, Quarantine & Remediation Policy
|
|
36
|
+
|
|
37
|
+
Flaky tests are any test that passes and fails intermittently without code changes (this could be due to things like timeouts, inconsistent return values, poor assertions, etc). Flaky tests erode confidence in the test suite and slow down development. This section defines how we detect, quarantine, and remediate them.
|
|
38
|
+
|
|
39
|
+
#### Detection
|
|
40
|
+
|
|
41
|
+
- **Automatic retries**: Jest unit tests can be configured to automatically retry on failure via `jest.retryTimes()`. Playwright integration tests (where applicable) have retries configured per-project. A test that fails once but passes on retry can be considered as potentially flaky.
|
|
42
|
+
- **Repeat failures**: If a test fails intermittently across multiple CI runs or PRs, it should be reported by opening a GitHub issue with the `flaky-test` label. Include the test name, file path, failure frequency, and any relevant error output.
|
|
43
|
+
|
|
44
|
+
#### Quarantine
|
|
45
|
+
|
|
46
|
+
When a test is confirmed flaky:
|
|
47
|
+
|
|
48
|
+
1. **Open a tracking issue** in GitHub Issues. Use the `flaky-test` label and include:
|
|
49
|
+
- Test file path and test name
|
|
50
|
+
- Observed failure rate and pattern (e.g., "fails ~10% of runs", "only in CI")
|
|
51
|
+
- Stack trace or error message
|
|
52
|
+
2. **Skip the test** using `.skip` and add a comment referencing the tracking issue:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
// Quarantined: flaky due to timing sensitivity (https://github.com/braintree/sanitize-url/issues/123)
|
|
56
|
+
it.skip("should handle the edge case", function () {
|
|
57
|
+
// ...
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For `describe` blocks with multiple flaky tests, you may quarantine the entire block:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// Quarantined: intermittent failures under load (https://github.com/braintree/sanitize-url/issues/123)
|
|
65
|
+
describe.skip("feature under investigation", function () {
|
|
66
|
+
// ...
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. **Skipped tests are excluded from coverage reporting.** Since quarantined tests do not execute, their associated source code is not counted toward coverage metrics. This is expected and acceptable while the test is in quarantine.
|
|
71
|
+
|
|
72
|
+
#### Remediation SLA
|
|
73
|
+
|
|
74
|
+
Quarantined tests must be remedied within **30 days** of being quarantined. Remediation means one of the following:
|
|
75
|
+
|
|
76
|
+
- **Fixed**: The root cause is identified and corrected, the `.skip` is removed, and the test passes reliably.
|
|
77
|
+
- **Deleted**: If the test is no longer valuable or the feature it covers has changed, delete the test and close the tracking issue.
|
|
78
|
+
|
|
79
|
+
If a quarantined test exceeds **14 days** without progress, it should be escalated and prioritized. Tests that remain skipped indefinitely are not acceptable.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Braintree
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|