Utilizing document.referrer with Knack? JavaScript

I'm trying to read the referrer URL in order to redirect the user back to the details page. There might be a simpler way to do this, but basically I'm trying to read the incoming URL and redirect the user back to the project page once the print function is complete.

The problem I'm running into is the string that document.referrer returns. It does not look like the actual URL, but looks like this:

https://app.knack.com/appname?state=p%3Dgoogle%26s%3Dhome%26h%3Dhome&code=4/UADRJSVK5EPV9c5tX5pJMI_99b3i8jhLjuu8-eG_TxN6fpRzDdLy6mmwqFKIpKIs8uNl1BvOngvvs2pyVcCjxSE

And my script looks like this:

$(document).on('knack-scene-render.scene_96', function(event, scene) {
var referingPage = document.referrer;
setTimeout(function() {
window.print()
}, 900);
if (referingPage.indexOf("project-details") > -1) {
setTimeout(function() {
window.history.back()
}, 1000);
}

if (referingPage.indexOf("print-custom") > -1) {
setTimeout(function() {
window.history.go(-2);
}, 1000);
}
});

I could do that Brad, but I sometimes need to go back two pages depending on how the user is getting to the print page view. For now, I'm kind of doing that with the a redirect back to the details page. It works, but starts adding pages to the breadcrumb.

 var backURL = document.querySelector('#view_446 .kn-link-page').href;
setTimeout(function() {
window.print()
}, 900);
setTimeout(function() {
window.location.href = backURL;
}, 1200);

Could you trigger the back link after the window.print instead?

$('.kn-view.kn-back-link').click();