vite-plugin-sri4 1.4.0 → 1.6.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/dist/index.cjs +4 -5
- package/dist/index.js +4 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -87,7 +87,7 @@ function isBypassDomain(url, bypassDomains = []) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function hasCrossOriginAttr(tag) {
|
|
90
|
-
return /crossorigin
|
|
90
|
+
return /(?:^|\s)crossorigin(?:=["']?[^"'\s>]*["']?)?(?:\s|>|$)/i.test(tag);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function sri(userOptions = {}) {
|
|
@@ -96,7 +96,6 @@ function sri(userOptions = {}) {
|
|
|
96
96
|
|
|
97
97
|
return {
|
|
98
98
|
name: 'vite-plugin-sri4',
|
|
99
|
-
enforce: 'post',
|
|
100
99
|
apply: 'build',
|
|
101
100
|
|
|
102
101
|
configResolved(config) {
|
|
@@ -149,15 +148,15 @@ function sri(userOptions = {}) {
|
|
|
149
148
|
|
|
150
149
|
if (integrity) {
|
|
151
150
|
const hasCrossOrigin = hasCrossOriginAttr(tag);
|
|
152
|
-
if (hasCrossOrigin) {
|
|
151
|
+
if (!hasCrossOrigin) {
|
|
153
152
|
return tag.replace(
|
|
154
153
|
/>$/,
|
|
155
|
-
` integrity="${integrity}">`
|
|
154
|
+
` integrity="${integrity}" crossorigin="${options.crossorigin}">`
|
|
156
155
|
);
|
|
157
156
|
}
|
|
158
157
|
return tag.replace(
|
|
159
158
|
/>$/,
|
|
160
|
-
` integrity="${integrity}"
|
|
159
|
+
` integrity="${integrity}">`
|
|
161
160
|
);
|
|
162
161
|
}
|
|
163
162
|
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ function isBypassDomain(url, bypassDomains = []) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function hasCrossOriginAttr(tag) {
|
|
88
|
-
return /crossorigin
|
|
88
|
+
return /(?:^|\s)crossorigin(?:=["']?[^"'\s>]*["']?)?(?:\s|>|$)/i.test(tag);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function sri(userOptions = {}) {
|
|
@@ -94,7 +94,6 @@ function sri(userOptions = {}) {
|
|
|
94
94
|
|
|
95
95
|
return {
|
|
96
96
|
name: 'vite-plugin-sri4',
|
|
97
|
-
enforce: 'post',
|
|
98
97
|
apply: 'build',
|
|
99
98
|
|
|
100
99
|
configResolved(config) {
|
|
@@ -147,15 +146,15 @@ function sri(userOptions = {}) {
|
|
|
147
146
|
|
|
148
147
|
if (integrity) {
|
|
149
148
|
const hasCrossOrigin = hasCrossOriginAttr(tag);
|
|
150
|
-
if (hasCrossOrigin) {
|
|
149
|
+
if (!hasCrossOrigin) {
|
|
151
150
|
return tag.replace(
|
|
152
151
|
/>$/,
|
|
153
|
-
` integrity="${integrity}">`
|
|
152
|
+
` integrity="${integrity}" crossorigin="${options.crossorigin}">`
|
|
154
153
|
);
|
|
155
154
|
}
|
|
156
155
|
return tag.replace(
|
|
157
156
|
/>$/,
|
|
158
|
-
` integrity="${integrity}"
|
|
157
|
+
` integrity="${integrity}">`
|
|
159
158
|
);
|
|
160
159
|
}
|
|
161
160
|
|