summaryrefslogtreecommitdiff
path: root/src/api/common/text/elements/url.ts
blob: 1003aff9c3bc6bec3806f97415aa6e6724310223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * URL
 */

module.exports = text => {
	const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
	if (!match) return null;
	const url = match[0];
	return {
		type: 'url',
		content: url,
		url: url
	};
};