autolinker
Version:
Utility to automatically link the URLs, email addresses, phone numbers, hashtags, and mentions (Twitter, Instagram) in a given block of text/HTML
1 lines • 2.83 kB
Source Map (JSON)
{"version":3,"file":"email-match.js","sourceRoot":"","sources":["../../../src/match/email-match.ts"],"names":[],"mappings":";;;;AAAA,mDAAsE;AAEtE;;;;;;;GAOG;AACH;IAAgC,sCAAa;IAkBzC;;;;OAIG;IACH,oBAAY,GAAqB;QAC7B,YAAA,MAAK,YAAC,GAAG,CAAC,SAAC;QAvBf;;;;;;;WAOG;QACa,UAAI,GAAG,OAAgB,CAAC;QAExC;;;;WAIG;QACc,WAAK,GAAW,EAAE,CAAC,CAAC,gGAAgG;QAUjI,KAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;;IAC3B,CAAC;IAED;;;;;OAKG;IACH,4BAAO,GAAP;QACI,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,6BAAQ,GAAR;QACI,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,kCAAa,GAAb;QACI,OAAO,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,kCAAa,GAAb;QACI,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACL,iBAAC;AAAD,CAAC,AAjED,CAAgC,8BAAa,GAiE5C;AAjEY,gCAAU","sourcesContent":["import { AbstractMatchConfig, AbstractMatch } from './abstract-match';\n\n/**\n * @class Autolinker.match.Email\n * @extends Autolinker.match.AbstractMatch\n *\n * Represents a Email match found in an input string which should be Autolinked.\n *\n * See this class's superclass ({@link Autolinker.match.Match}) for more details.\n */\nexport class EmailMatch extends AbstractMatch {\n /**\n * @public\n * @property {'email'} type\n *\n * A string name for the type of match that this class represents. Can be\n * used in a TypeScript discriminating union to type-narrow from the\n * `Match` type.\n */\n public readonly type = 'email' as const;\n\n /**\n * @cfg {String} email (required)\n *\n * The email address that was matched.\n */\n private readonly email: string = ''; // default value just to get the above doc comment in the ES5 output and documentation generator\n\n /**\n * @method constructor\n * @param {Object} cfg The configuration properties for the Match\n * instance, specified in an Object (map).\n */\n constructor(cfg: EmailMatchConfig) {\n super(cfg);\n\n this.email = cfg.email;\n }\n\n /**\n * Returns a string name for the type of match that this class represents.\n * For the case of EmailMatch, returns 'email'.\n *\n * @return {String}\n */\n getType(): 'email' {\n return 'email';\n }\n\n /**\n * Returns the email address that was matched.\n *\n * @return {String}\n */\n getEmail() {\n return this.email;\n }\n\n /**\n * Returns the anchor href that should be generated for the match.\n *\n * @return {String}\n */\n getAnchorHref() {\n return 'mailto:' + this.email;\n }\n\n /**\n * Returns the anchor text that should be generated for the match.\n *\n * @return {String}\n */\n getAnchorText() {\n return this.email;\n }\n}\n\nexport interface EmailMatchConfig extends AbstractMatchConfig {\n email: string;\n}\n"]}