Stop looping on URL fixing

This commit is contained in:
Brad Davis 2016-01-07 10:52:28 -08:00
parent 553e455a53
commit 144af19ebd

View file

@ -47,10 +47,20 @@ VrDialog {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
property var originalUrl
property var lastFixupTime: 0
onUrlChanged: { onUrlChanged: {
var currentUrl = url.toString(); var currentUrl = url.toString();
var newUrl = urlHandler.fixupUrl(currentUrl).toString(); var newUrl = urlHandler.fixupUrl(currentUrl).toString();
if (newUrl != currentUrl) { if (newUrl != currentUrl) {
var now = new Date().valueOf();
if (url === originalUrl && (now - lastFixupTime < 100)) {
console.warn("URL fixup loop detected")
return;
}
originalUrl = url
lastFixupTime = now
url = newUrl; url = newUrl;
} }
} }