diff --git a/src/lib/app/markdown/renderers/plugins.js b/src/lib/app/markdown/renderers/plugins.js index 8a84fd70..8d24d6bb 100644 --- a/src/lib/app/markdown/renderers/plugins.js +++ b/src/lib/app/markdown/renderers/plugins.js @@ -94,7 +94,6 @@ export const linkify = markedLinkifyIt( const regexes = { user: /^https:\/\/([a-zA-Z0-9.-]+)(\/u\/)([a-zA-Z0-9.-_]+)$/i, community: /^https:\/\/([a-zA-Z0-9.-]+)(\/c\/)([a-zA-Z0-9.-_]+)$/i, - implicitUser: /^mailto:([a-z0-9_.-]+)@(([\da-z.-]+)\.([a-z]{2,63}))/i, } export { regexes as CONTENT_REGEXES } @@ -119,13 +118,9 @@ export const localizeLink = (link) => { if (match?.[3].includes('@')) return `/profile/${match?.[3]}` else return `/profile/${match?.[3]}@${match?.[1]}` } - // Support implicit user syntax (no preceding @), by messing with mailto links. - if (regexes.implicitUser.test(link)) { - const exec = regexes.implicitUser.exec(link) - - if (!exec?.[1] || !exec?.[2]) return - return `/profile/${exec[1]}@${exec[2]}` - } + // NOTE: mailto: links are deliberately left untouched. The old Lemmy-era + // "implicit user mention" rewrite turned every real email link (e.g. + // support@coves.social on /legal) into a dead /profile/ link. } export function subSupscriptExtension(tokensExtractor) { diff --git a/src/lib/app/markdown/renderers/plugins.test.ts b/src/lib/app/markdown/renderers/plugins.test.ts index 9e6626b6..ee8375fd 100644 --- a/src/lib/app/markdown/renderers/plugins.test.ts +++ b/src/lib/app/markdown/renderers/plugins.test.ts @@ -28,23 +28,16 @@ describe('localizeLink - user links', () => { }) // --------------------------------------------------------------------------- -// localizeLink() - implicit user links (mailto) +// localizeLink() - mailto links stay untouched (real email links must work) // --------------------------------------------------------------------------- -describe('localizeLink - implicit user links (mailto)', () => { - it('rewrites mailto link to /profile/ path', () => { - const result = localizeLink('mailto:alice@coves.social') - expect(result).toBe('/profile/alice@coves.social') +describe('localizeLink - mailto links', () => { + it('leaves plain mailto links untouched', () => { + expect(localizeLink('mailto:alice@coves.social')).toBeUndefined() }) - it('rewrites mailto link with subdomain instance', () => { - const result = localizeLink('mailto:bob@lemmy.world') - expect(result).toBe('/profile/bob@lemmy.world') - }) - - it('handles username with dots and hyphens', () => { - const result = localizeLink('mailto:first.last@example.org') - expect(result).toBe('/profile/first.last@example.org') + it('leaves mailto links with dots and hyphens untouched', () => { + expect(localizeLink('mailto:first.last@example.org')).toBeUndefined() }) }) @@ -116,11 +109,4 @@ describe('CONTENT_REGEXES', () => { true, ) }) - - it('exports implicitUser regex', () => { - expect(CONTENT_REGEXES.implicitUser).toBeInstanceOf(RegExp) - expect(CONTENT_REGEXES.implicitUser.test('mailto:alice@coves.social')).toBe( - true, - ) - }) })