I've decided to solve this by monkey patching m.route.set
. The below code will check to see if the path looks like a url i.e. it contains ://
and if so, assume it's an external url - these wouldn't match in Mithril routing, so it makes sense to fallback onto manual page navigation.
This may not be the most eloquent solution, but it's super simple, and gives full control over routing. Hope it helps.
function shouldSkipRouting(path) {
// If it looks like a url, skip Mithril routing
return path.indexOf('://') > -1;
}
const mset = m.route.set;
window.m.route.set = function(path, params, options) {
if (shouldSkipRouting(path)) {
window.location.href = path;
} else {
return mset.call(this, path, params, options);
}
}