Merge pull request #1604 from thelounge/greenkeeper/urijs-1.19.0
Update urijs to the latest version 🚀
This commit is contained in:
commit
530d71764f
@ -22,41 +22,45 @@ function findLinks(text) {
|
|||||||
// <a>-Tags.
|
// <a>-Tags.
|
||||||
// See https://medialize.github.io/URI.js/docs.html#static-withinString
|
// See https://medialize.github.io/URI.js/docs.html#static-withinString
|
||||||
// In our case, we store each URI encountered in a result array.
|
// In our case, we store each URI encountered in a result array.
|
||||||
URI.withinString(text, function(url, start, end) {
|
try {
|
||||||
let parsedScheme;
|
URI.withinString(text, function(url, start, end) {
|
||||||
|
let parsedScheme;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Extract the scheme of the URL detected, if there is one
|
// Extract the scheme of the URL detected, if there is one
|
||||||
parsedScheme = URI(url).scheme().toLowerCase();
|
parsedScheme = URI(url).scheme().toLowerCase();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// URI may throw an exception for malformed urls,
|
// URI may throw an exception for malformed urls,
|
||||||
// as to why withinString finds these in the first place is a mystery
|
// as to why withinString finds these in the first place is a mystery
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the scheme of the detected URL matches a common one above.
|
// Check if the scheme of the detected URL matches a common one above.
|
||||||
// In a URL like `foo..http://example.com`, the scheme would be `foo..http`,
|
// In a URL like `foo..http://example.com`, the scheme would be `foo..http`,
|
||||||
// so we need to clean up the end of the scheme and filter out the rest.
|
// so we need to clean up the end of the scheme and filter out the rest.
|
||||||
const matchedScheme = commonSchemes.find((scheme) => parsedScheme.endsWith(scheme));
|
const matchedScheme = commonSchemes.find((scheme) => parsedScheme.endsWith(scheme));
|
||||||
|
|
||||||
// A known scheme was found, extract the unknown part from the URL
|
// A known scheme was found, extract the unknown part from the URL
|
||||||
if (matchedScheme) {
|
if (matchedScheme) {
|
||||||
const prefix = parsedScheme.length - matchedScheme.length;
|
const prefix = parsedScheme.length - matchedScheme.length;
|
||||||
start += prefix;
|
start += prefix;
|
||||||
url = url.slice(prefix);
|
url = url.slice(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The URL matched but does not start with a scheme (`www.foo.com`), add it
|
// The URL matched but does not start with a scheme (`www.foo.com`), add it
|
||||||
if (!parsedScheme.length) {
|
if (!parsedScheme.length) {
|
||||||
url = "http://" + url;
|
url = "http://" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
start: start,
|
start: start,
|
||||||
end: end,
|
end: end,
|
||||||
link: url
|
link: url
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} catch (e) {
|
||||||
|
// withinString is wrapped in a try/catch due to https://github.com/medialize/URI.js/issues/359
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
"socket.io": "1.7.4",
|
"socket.io": "1.7.4",
|
||||||
"spdy": "3.4.7",
|
"spdy": "3.4.7",
|
||||||
"ua-parser-js": "0.7.14",
|
"ua-parser-js": "0.7.14",
|
||||||
"urijs": "1.18.12",
|
"urijs": "1.19.0",
|
||||||
"web-push": "3.2.3"
|
"web-push": "3.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user