mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
e8878e5ce8
Fixes GitHub Issues #479 and #335
16 lines
677 B
CoffeeScript
16 lines
677 B
CoffeeScript
Autolinker = require 'autolinker'
|
|
{MessageStoreExtension} = require 'nylas-exports'
|
|
|
|
class AutolinkerExtension extends MessageStoreExtension
|
|
|
|
@formatMessageBody: (message) ->
|
|
# Apply the autolinker pass to make emails and links clickable
|
|
message.body = Autolinker.link(message.body, {twitter: false})
|
|
|
|
# Ensure that the hrefs in the email always have alt text so you can't hide
|
|
# the target of links
|
|
# https://regex101.com/r/cH0qM7/1
|
|
message.body = message.body.replace /href[ ]*=[ ]*?['"]([^'"]*)(['"]+)/gi, (match, url, quoteCharacter) =>
|
|
return "#{match} title=#{quoteCharacter}#{url}#{quoteCharacter} "
|
|
|
|
module.exports = AutolinkerExtension
|