Fix an edge case where we cannot find any shortUrl

pull/480/head
Haocen Xu 2019-08-14 00:02:25 -04:00
parent a5cd8696e6
commit 1af7b536a5
No known key found for this signature in database
GPG Key ID: 3F0D955A0F6AD729
1 changed files with 1 additions and 1 deletions

View File

@ -1730,7 +1730,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
}
if (typeof responseString === 'string' && responseString.length > 0) {
const shortUrlMatcher = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
const shortUrl = responseString.match(shortUrlMatcher).sort(function(a, b) {
const shortUrl = (responseString.match(shortUrlMatcher) || []).sort(function(a, b) {
return a.length - b.length;
})[0];
if (typeof shortUrl === 'string' && shortUrl.length > 0) {