summaryrefslogtreecommitdiff
path: root/src/common/text/elements/url.js
blob: d02aef0800cfb56da39120cd470379180a9ec6fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * 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
		};
	}
};