17 lines
289 B
JavaScript
17 lines
289 B
JavaScript
|
/**
|
||
|
* URL
|
||
|
*/
|
||
|
|
||
|
const regexp = /https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/;
|
||
|
|
||
|
module.exports = {
|
||
|
test: x => new RegExp('^' + regexp.source).test(x),
|
||
|
parse: text => {
|
||
|
const link = text.match(new RegExp('^' + regexp.source))[0];
|
||
|
return {
|
||
|
type: 'link',
|
||
|
content: link
|
||
|
};
|
||
|
}
|
||
|
};
|