summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-06-19 10:17:33 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-06-19 10:17:33 +0200
commit20a83b0b3baa42d3f4ccb8fe267ca979402366bf (patch)
treee3566045e0b53a9ac02713c59238f5755502314b
parentdb7ccba54d97f4a823dab9dbf2bcac72a1891e96 (diff)
Fix 404 handling for google site ownership file
-rwxr-xr-xwebserver.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/webserver.js b/webserver.js
index b53d9ab..4b49412 100755
--- a/webserver.js
+++ b/webserver.js
@@ -159,7 +159,11 @@ app.get("/.well-known/*", function (req, res) {
app.get("/google*.html", function (req, res) {
const url = unescape(makeUrlSafe(req, 0));
if (url.match(/^\/google[0-9a-fA-F]*\.html$/)) {
- res.sendFile(__dirname + url);
+ const fname = __dirname + url;
+ fs.exists(fname, fs.constants.R_OK, err => {
+ if (err) res.status(400).send("That file does not exist.");
+ else res.sendFile(fname);
+ });
} else {
res.status(404).send("That file does not exist.");
}