diff --git a/lib/url.spec.js b/lib/url.spec.js index 9216035f..829cc38c 100644 --- a/lib/url.spec.js +++ b/lib/url.spec.js @@ -7,6 +7,8 @@ const cases = [ ['https://stacker.news/items/123/related', '#123/related'], // invalid links should not be parsed so user can spot error ['https://stacker.news/items/123foobar', undefined], + // Invalid origin should not be parsed so no malicious links + ['https://example.com/items/123', undefined], // parse referral links ['https://stacker.news/items/123/r/ekzyis', '#123'], // use comment id if available @@ -21,6 +23,7 @@ describe('internal links', () => { test.each(cases)( 'parses %p as %p', (href, expected) => { + process.env.NEXT_PUBLIC_URL = 'https://stacker.news' const actual = parseInternalLinks(href) expect(actual).toBe(expected) }