Skip to content

Commit af851f8

Browse files
committed
Don’t allow invalid regex to result in JS error
Fixes #4765
1 parent 9ae4e63 commit af851f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/resources/formats/html/templates/quarto-html.ejs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,10 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
596596
597597
<% if (linkExternalIcon || linkExternalNewwindow) { %>
598598
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
599-
<% if (linkExternalFilter) { %>
599+
<% if (linkExternalFilter && linkExternalFilter.match(/\\\\/)) { %>
600600
<%- `var filterRegex = new RegExp(/${linkExternalFilter}/);` %>
601+
<% } else if (linkExternalFilter) { %>
602+
<%= `var filterRegex = new RegExp("${linkExternalFilter}");` %>
601603
<% } else { %>
602604
var filterRegex = new RegExp('/' + window.location.host + '/');
603605
<% } %>

0 commit comments

Comments
 (0)