fix: parseInternalLinks test (#1050)

This commit is contained in:
Ben Allen 2024-04-09 15:44:45 -04:00 committed by GitHub
parent 6d57bbffe5
commit 255ad29897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -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)
}