mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
improve regex for url parse
This commit is contained in:
parent
e39a7cc16b
commit
1002e0baeb
1 changed files with 5 additions and 5 deletions
|
|
@ -402,13 +402,13 @@ function tryParseUrl(urlStr) {
|
|||
return null;
|
||||
}
|
||||
|
||||
// a regular expression to match URLs
|
||||
var regex = /(https?:\/\/[^\s]+)/g;
|
||||
// a regular expression to match all URLs
|
||||
const regex = /(https?:\/\/[^\s]+)/g;
|
||||
|
||||
var match = regex.exec(urlStr);
|
||||
const matches = urlStr.match(regex);
|
||||
|
||||
if (match) {
|
||||
return match[1];
|
||||
if (matches) {
|
||||
return matches[0]; // only return first match
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue