Closed PaulMaly closed 5 years ago
Also, pathname includes absolute path to the file, but seems should be a relative path.
Probably, we also need to use pageBase instead of base here:
if (path.indexOf(pageBase) === 0) {
path = path.substr(base.length);
}
I'm also needing to get hashbang and file://
working with regular <a href></a>
links.
Does this makes sense?
if (pageBase && orig === path && (!isLocation || this._window.location.protocol !== 'file:')) {
return;
}
(check for isLocation
and the location.protocol
)
I'm not sure I understand the situation to be honest. If you could create an HTML file that I can drop into a browser with the file protocol I can dive into it.
Sure! Based on the basic
example:
<!DOCTYPE html>
<html>
<head>
<title>page: hashbang + file: protocol issue</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/page.js/1.10.2/page.js"></script>
</head>
<body>
<p></p>
<ul>
<li><a href="./">/</a></li>
<li><a href="./about">/about</a></li>
</ul>
<script>
page('/', index);
page('/about', about);
page.start({ hashbang: true });
function index() {
document.querySelector('p')
.textContent = 'viewing index';
}
function about() {
document.querySelector('p')
.textContent = 'viewing about';
}
</script>
</body>
</html>
With file protocol:
With http protocol:
@kaisermann could you please provide a PR for your fix?
@PaulMaly Sure, no problem! However, I'm not sure if this is really the right way of fixing it (I didn't understand completely the pageBase && orig === path
condition). @matthewp any thoughts?
@kaisermann I don't know is that the best way or not, but seems it should work, so I think it's an appropriate solution anyway.
@matthewp I think this can be closed now :grin:
Yep, thank you!
When onclick event fired, we've got situation then handler never handle navigation, because this condition is always true:
How to fix that?