Skip to content

Commit dd2fbbd

Browse files
author
patj
committed
build.py: function repl in script inlining (JS backslashes broke re.sub)
1 parent 1572382 commit dd2fbbd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎scripts/build.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def main():
3737
# script src would break execution in the single-file bundle.
3838
with open(os.path.join(ROOT, "assets/js/downloads.js"), encoding="utf-8") as f:
3939
js = f.read()
40+
# Function replacement: a plain-string repl would interpret backslashes
41+
# in the JS (e.g. regex \d) as re escape sequences and crash.
4042
html = re.sub(
4143
r'<script src="assets/js/downloads\.js[^"]*"[^>]*></script>',
42-
f"<script>\n{js}\n</script>",
44+
lambda _m: f"<script>\n{js}\n</script>",
4345
html,
4446
)
4547

0 commit comments

Comments
 (0)