You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite CDN asset URLs in HTML to local /vendor/ paths.
88
-
89
-
Replaces known external CDN links (React, Babel, Tailwind, PrismJS, FontAwesome, etc.) with corresponding /vendor/... paths and removes `integrity` and `crossorigin` attributes from `<link>` and `<script>` tags that reference those local vendor files.
90
-
87
+
Rewrite HTML to replace known CDN asset URLs with local `/vendor/` paths and remove SRI and crossorigin attributes from tags that reference those local assets.
88
+
91
89
Parameters:
92
90
content (str): HTML document content to rewrite.
93
-
91
+
94
92
Returns:
95
-
str: The HTML content with matching CDN URLs substituted by local vendor URLs and SRI/crossorigin attributes stripped for vendored assets.
93
+
str: HTML content with matching CDN URLs substituted by local `/vendor/` URLs and `integrity`/`crossorigin` attributes removed from tags that reference `/vendor/`.
94
+
"""
95
+
"""
96
+
Remove `integrity` and `crossorigin` attributes from a matched <link> or <script> tag when it references a `/vendor/` path.
97
+
98
+
Parameters:
99
+
match (typing.Match[str]): A regex match whose matched text is the full HTML tag.
100
+
101
+
Returns:
102
+
str: The tag text with `integrity` and `crossorigin` attributes removed if the tag contains `/vendor/`, otherwise the original tag text.
# Strip integrity and crossorigin attributes from tags referencing local /vendor/ files
126
133
defstrip_sri(match: re.Match[str]) ->str:
127
134
"""
128
-
Remove Subresource Integrity (`integrity`) and `crossorigin` attributes from an HTML <link> or <script> tag if the tag references a `/vendor/` path.
129
-
135
+
Remove `integrity` and `crossorigin` attributes from an HTML `<link>` or `<script>` tag that references a `/vendor/` path.
136
+
130
137
Parameters:
131
-
match (re.Match): A regex match object whose matched text is the full HTML tag.
132
-
138
+
match (typing.Match[str]): Regex match whose matched text is the full HTML tag to process.
139
+
133
140
Returns:
134
-
str: The original tag text with `integrity` and `crossorigin` attributes removed when the tag contains `/vendor/`; otherwise the original tag text unchanged.
141
+
str: The tag text with `integrity` and `crossorigin` attributes removed if the tag contains `/vendor/`, otherwise the original tag text.
0 commit comments