Skip to content

Commit f8ed852

Browse files
committed
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStudy into dev-from-macmini
# Conflicts: # generate_index.py # public/index.html
2 parents d4e68be + 9a3c530 commit f8ed852

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

generate_index.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ def copy_vendor_files(self, output_dir: str) -> None:
7878

7979
def rewrite_html_content(self, content: str) -> str:
8080
"""
81-
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.
8282
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.
8487
8588
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.
8790
"""
8891
replacements = [
8992
# React
@@ -114,6 +117,15 @@ def rewrite_html_content(self, content: str) -> str:
114117

115118
# Strip integrity and crossorigin attributes from tags referencing local /vendor/ files
116119
def strip_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.
128+
"""
117129
tag_text = match.group(0)
118130
if '/vendor/' in tag_text:
119131
tag_text = re.sub(r'\s*integrity="[^"]+"', '', tag_text)

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ <h1 class="site-title">
793793

794794
<footer>
795795
<span class="footer-icon">🧪</span>
796-
Generated on 2026-02-26 05:30:53 UTC
796+
Generated on 2026-02-26 05:32:54 UTC
797797
</footer>
798798

799799
<script>

0 commit comments

Comments
 (0)