import test from 'node:test'; import assert from 'node:assert/strict'; import { isSafePostLoginRedirect } from './data.js'; test('isSafePostLoginRedirect only allows same-origin relative paths', () => { for (const ok of [ '/console', '/client/authorize?client_id=weyai-desktop&state=a%5Cb', ]) { assert.equal(isSafePostLoginRedirect(ok), true, ok); } for (const bad of [ '', 'https://evil.example.com', '//evil.example.com', '/\\evil.example.com', '/\\/evil.example.com', '/console\\..\\x', '/login', '/org/login', ]) { assert.equal(isSafePostLoginRedirect(bad), false, bad); } });