This commit is contained in:
parent
08ca42693b
commit
424721b98c
4
index.ts
4
index.ts
|
@ -18,6 +18,10 @@ export const ISSUE_REPORT =
|
|||
process.env.ISSUE_REPORT ?? "mailto:kill-the-newsletter@leafac.com";
|
||||
|
||||
export const webServer = express()
|
||||
.use(["/feeds", "/alternate"], (req, res, next) => {
|
||||
res.header("X-Robots-Tag", "noindex");
|
||||
next();
|
||||
})
|
||||
.use(express.static("static"))
|
||||
.use(express.urlencoded({ extended: true }))
|
||||
.get("/", (req, res) => res.send(layout(newInbox())))
|
||||
|
|
14
test.ts
14
test.ts
|
@ -221,6 +221,20 @@ describe("receive email", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test("‘noindex’ header", async () => {
|
||||
const identifier = await createFeed();
|
||||
const feed = await getFeed(identifier);
|
||||
const entry = feed.querySelector("feed > entry:first-of-type")!;
|
||||
const alternatePath = entry.querySelector("link")!.getAttribute("href")!;
|
||||
expect((await webClient.get(`/`)).headers["x-robots-tag"]).toBeUndefined();
|
||||
expect(
|
||||
(await webClient.get(`/feeds/${identifier}.xml`)).headers["x-robots-tag"]
|
||||
).toBe("noindex");
|
||||
expect((await webClient.get(alternatePath)).headers["x-robots-tag"]).toBe(
|
||||
"noindex"
|
||||
);
|
||||
});
|
||||
|
||||
const webClient = axios.create({
|
||||
baseURL: BASE_URL,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue