text-parser-url
text parser to parse url
Install
npm i text-parser-url
quick start
const textParserUrl = const result = // =>// [ // { type: 'raw', value: 'project address: ' },// { type: 'url', value: 'https://github.com/heineiuo/text-parser-url' },// { type: 'raw', value: ', author: ' },// { type: 'url', value: 'https://github.com/heineiuo' },// { type: 'raw', value: ' enjoy it!' } // ]
Options
onToken
const textParserUrl = let len = 0const result = // =>// [ // { type: 'raw', value: 'project address: ', len: 0 },// { type: 'url', value: 'https://github.com/heineiuo/text-parser-url', len: 17 },// { type: 'raw', value: ', author: ', len: 60 },// { type: 'url', value: 'https://github.com/heineiuo', len: 70 },// { type: 'raw', value: ' enjoy it!', len: 97 } // ]
requireProtocol
const textParserUrl = // =>// [ // { type: 'raw', value: 'www.github.com' },// ] // =>// [ // { type: 'url', value: 'www.github.com' },// ]
regex
custom url regex. requireProtocol will be disabled
License
MIT