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 known CDN asset URLs in an HTML document to their corresponding local vendor paths.
81
+
Rewrite CDN asset URLs in HTML to local /vendor/ paths.
82
82
83
-
Replaces specific external CDN links (React, Babel, Tailwind, PrismJS, FontAwesome, etc.) with local /vendor/... paths so the returned HTML references vendored assets.
83
+
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.
84
+
85
+
Parameters:
86
+
content (str): HTML document content to rewrite.
84
87
85
88
Returns:
86
-
The input HTML string with matched CDN URLs substituted by local vendor URLs.
89
+
str: The HTML content with matching CDN URLs substituted by local vendor URLs and SRI/crossorigin attributes stripped for vendored assets.
# Strip integrity and crossorigin attributes from tags referencing local /vendor/ files
116
119
defstrip_sri(match: typing.Match[str]) ->str:
120
+
"""
121
+
Remove Subresource Integrity (`integrity`) and `crossorigin` attributes from an HTML <link> or <script> tag if the tag references a `/vendor/` path.
122
+
123
+
Parameters:
124
+
match (re.Match): A regex match object whose matched text is the full HTML tag.
125
+
126
+
Returns:
127
+
str: The original tag text with `integrity` and `crossorigin` attributes removed when the tag contains `/vendor/`; otherwise the original tag text unchanged.
0 commit comments