Skip to content

Commit

Permalink
Merge pull request #672 from w3c/express5-patch
Browse files Browse the repository at this point in the history
with express 5, req.query is no longer writable. Use a different property instead
  • Loading branch information
deniak authored Dec 9, 2024
2 parents 9512b46 + 725188e commit 8984505
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ app.get(
.json({ error: `Unknown generator: ${req.query.type}` });
}
const specURL = new URL(url);
req.targetURL = req.query.url;
if (specURL.hostname === "raw.githubusercontent.com") {
const uploadPath = await mkdtemp("uploads/");
const originalDocument = await fetch(url);
Expand Down Expand Up @@ -148,13 +149,13 @@ app.get(

const baseUrl = `${req.protocol}://${req.get("host")}/`;
const newPath = url.replace(baseRegex, `${uploadPath}/`);
req.query.url = `${baseUrl}${newPath}${specURL.search}`;
req.targetURL = `${baseUrl}${newPath}${specURL.search}`;
req.tmpDir = uploadPath;
}
next();
},
async (req, res) => {
const specURL = new URL(req.query.url);
const specURL = new URL(req.targetURL);
const publishDate =
specURL.searchParams.get("publishDate") || getShortIsoDate();

Expand Down

0 comments on commit 8984505

Please sign in to comment.