Refactoring ✨
This commit is contained in:
@@ -2,15 +2,12 @@
|
||||
* 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
|
||||
};
|
||||
}
|
||||
module.exports = text => {
|
||||
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
|
||||
if (!match) return null;
|
||||
const link = match[0];
|
||||
return {
|
||||
type: 'link',
|
||||
content: link
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user