mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-02-05 03:24:17 +00:00
retry to decode shortened URI if we got null response
This commit is contained in:
parent
dccc5695e0
commit
c93474d3d5
@ -879,7 +879,7 @@ function fillElemWithTxt(elem, txt, htmlFormatMsgOpt) {
|
|||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchShortenedURI(req) {
|
function fetchShortenedURI(req, attemptCount) {
|
||||||
if (twister.URIs[req]) {
|
if (twister.URIs[req]) {
|
||||||
applyShortenedURI(req, twister.URIs[req]);
|
applyShortenedURI(req, twister.URIs[req]);
|
||||||
return;
|
return;
|
||||||
@ -888,13 +888,15 @@ function fetchShortenedURI(req) {
|
|||||||
decodeShortURI(req,
|
decodeShortURI(req,
|
||||||
function (req, ret) {
|
function (req, ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
twister.URIs[req] = ret;
|
twister.URIs[req.shortURI] = ret;
|
||||||
$.localStorage.set('twistaURIs', twister.URIs);
|
$.localStorage.set('twistaURIs', twister.URIs);
|
||||||
applyShortenedURI(req, ret);
|
applyShortenedURI(req.shortURI, ret);
|
||||||
} else {
|
} else {
|
||||||
console.warn('can\'t fetch URI "' + req + '": null response');
|
console.warn('can\'t fetch URI "' + req.shortURI + '": null response');
|
||||||
|
if ((req.attemptCount ? ++req.attemptCount : req.attemptCount = 1) < 3) // < $.Options.decodeShortURITriesMax
|
||||||
|
fetchShortenedURI(req.shortURI, req.attemptCount);
|
||||||
}
|
}
|
||||||
}, req
|
}, {short: req, attemptCount: attemptCount}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user