Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit fd0dcd8

Browse files
authored
Update apply-csp.js (#139)
Match cross-platform newline characters.
1 parent 835ee34 commit fd0dcd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_11ty/apply-csp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const addCspHash = async (rawContent, outputPath) => {
7373
const filePathPrettyURL = filePath.slice(0, -10); // blog/index.html -> /blog/
7474
try {
7575
const headers = fs.readFileSync(headersPath, { encoding: "utf-8" });
76-
const regExp = /(# \[csp headers\]\n)([\s\S]*)(# \[end csp headers\])/;
76+
const regExp = /(# \[csp headers\][\r\n]+)([\s\S]*)(# \[end csp headers\])/;
7777
const match = headers.match(regExp);
7878
if (!match) {
7979
throw `Check your _headers file. I couldn't find the text block for the csp headers:
@@ -118,7 +118,7 @@ const addCspHash = async (rawContent, outputPath) => {
118118
function parseHeaders(headersFile) {
119119
let currentFilename;
120120
let headers = {};
121-
for (let line of headersFile.split(/\n+/)) {
121+
for (let line of headersFile.split(/[\r\n]+/)) {
122122
if (!line) continue;
123123
if (/^\S/.test(line)) {
124124
currentFilename = line;

0 commit comments

Comments
 (0)