Skip to content

Commit 61381a9

Browse files
authored
Merge branch 'main' into dev-from-macmini
2 parents 82dcc39 + 1bfd8b8 commit 61381a9

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

generate_index.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ def copy_vendor_files(self, output_dir: str) -> None:
7777

7878
def rewrite_html_content(self, content: str) -> str:
7979
"""
80-
Rewrite known CDN asset URLs in an HTML document to their corresponding local vendor paths.
81-
82-
Replaces specific external CDN links (React, Babel, Tailwind, PrismJS, FontAwesome, etc.) with local /vendor/... paths so the returned HTML references vendored assets.
83-
80+
Rewrite CDN asset URLs in HTML to local /vendor/ paths.
81+
82+
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.
83+
84+
Parameters:
85+
content (str): HTML document content to rewrite.
86+
8487
Returns:
85-
The input HTML string with matched CDN URLs substituted by local vendor URLs.
88+
str: The HTML content with matching CDN URLs substituted by local vendor URLs and SRI/crossorigin attributes stripped for vendored assets.
8689
"""
8790
replacements = [
8891
# React
@@ -108,6 +111,15 @@ def rewrite_html_content(self, content: str) -> str:
108111

109112
# Strip integrity and crossorigin attributes from tags referencing local /vendor/ files
110113
def strip_sri(match):
114+
"""
115+
Remove Subresource Integrity (`integrity`) and `crossorigin` attributes from an HTML <link> or <script> tag if the tag references a `/vendor/` path.
116+
117+
Parameters:
118+
match (re.Match): A regex match object whose matched text is the full HTML tag.
119+
120+
Returns:
121+
str: The original tag text with `integrity` and `crossorigin` attributes removed when the tag contains `/vendor/`; otherwise the original tag text unchanged.
122+
"""
111123
tag_text = match.group(0)
112124
if '/vendor/' in tag_text:
113125
tag_text = re.sub(r'\s*integrity="[^"]+"', '', tag_text)

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ <h1 class="site-title">
794794
<footer>
795795
<span class="footer-icon">🧪</span>
796796
Generated on 2026-02-26 05:16:00 UTC
797+
797798
</footer>
798799

799800
<script>

0 commit comments

Comments
 (0)