Просмотр исходного кода

Fix an edge case where we cannot find any shortUrl

Haocen Xu 7 лет назад
Родитель
Сommit
1af7b536a5
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      js/privatebin.js

+ 1 - 1
js/privatebin.js

@@ -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) {