2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00

feat(201): add file:// replacement (#280)

* feat: add file://

* feat: add changeset
This commit is contained in:
Nikolay Kost
2025-03-09 20:37:21 +02:00
committed by GitHub
parent 66c0931f5c
commit 9a6986965e
3 changed files with 23 additions and 1 deletions
+17
View File
@@ -0,0 +1,17 @@
---
"@bbob/parser": minor
"@bbob/types": minor
"@bbob/cli": minor
"@bbob/core": minor
"@bbob/html": minor
"@bbob/plugin-helper": minor
"@bbob/preset": minor
"@bbob/preset-html5": minor
"@bbob/preset-react": minor
"@bbob/preset-vue": minor
"@bbob/react": minor
"@bbob/vue2": minor
"@bbob/vue3": minor
---
Now all file protocol urls will be escaped like `file://some/path/to/file` will be converted to `file%3A//some/path/to/file`
+1 -1
View File
@@ -54,7 +54,7 @@ function escapeAttrValue(value: string) {
.replace(/"/g, '"') .replace(/"/g, '"')
.replace(/'/g, ''') .replace(/'/g, ''')
// eslint-disable-next-line no-script-url // eslint-disable-next-line no-script-url
.replace(/(javascript|data|vbscript):/gi, '$1%3A'); .replace(/(javascript|data|vbscript|file):/gi, '$1%3A');
} }
/** /**
@@ -99,6 +99,11 @@ describe('@bbob/plugin-helper/helpers', () => {
href: `JAVASCRIPT:alert('hello')`, href: `JAVASCRIPT:alert('hello')`,
})).toBe(` onclick="JAVASCRIPT%3Aalert('hello')" href="JAVASCRIPT%3Aalert('hello')"`) })).toBe(` onclick="JAVASCRIPT%3Aalert('hello')" href="JAVASCRIPT%3Aalert('hello')"`)
}); });
test(`file:alert("hello")`, () => {
expect(attrsToString({
href: `file:///shared/customer_info/customer-name`,
})).toBe(` href="file%3A///shared/customer_info/customer-name"`)
});
test(`<tag>`, () => { test(`<tag>`, () => {
expect(attrsToString({ expect(attrsToString({
onclick: `<tag>`, onclick: `<tag>`,