Sharkey/src/common/text/elements/url.js

14 lines
219 B
JavaScript
Raw Normal View History

2016-12-29 07:49:51 +09:00
/**
* URL
*/
2017-02-11 02:32:00 +09:00
module.exports = text => {
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
if (!match) return null;
const link = match[0];
return {
type: 'link',
content: link
};
2016-12-29 07:49:51 +09:00
};