testComingBackStaysOnTheSite
After signing in, an app goes back only to a path of its own.
import { comingBack } from "#codebase/tcmts/atproto"; import assert from "node:assert/strict"; export const testComingBackStaysOnTheSite = () => { assert.equal(comingBack("/@alice.dev/geo?tab=code", "/"), "/@alice.dev/geo?tab=code"); for (const away of [ "//evil.example/", "/\\evil.example", "https://evil.example", "javascript:x", null, ]) assert.equal(comingBack(away, "/home"), "/home", String(away)); }