misskey-awawa/src/common/text/elements/url.js

14 lines
219 B
JavaScript
Raw Normal View History

2016-12-28 22:49:51 +00:00
/**
* URL
*/
2017-02-10 17:32:00 +00: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-28 22:49:51 +00:00
};