[noImplicitAny: true] src/text
This commit is contained in:
parent
871f886702
commit
8c40917cc2
16 changed files with 166 additions and 44 deletions
|
|
@ -2,7 +2,13 @@
|
|||
* URL
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementUrl = {
|
||||
type: "url"
|
||||
content: string
|
||||
url: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
|
||||
if (!match) return null;
|
||||
const url = match[0];
|
||||
|
|
@ -10,5 +16,5 @@ module.exports = text => {
|
|||
type: 'url',
|
||||
content: url,
|
||||
url: url
|
||||
};
|
||||
};
|
||||
} as TextElementUrl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue