WardCunningham / remodeling

The original wiki rewritten as a single page application
927 stars 99 forks source link

'undefined' in generated internal links #20

Closed WardCunningham closed 7 years ago

WardCunningham commented 7 years ago

Peter reports via email: after a wiki page loads, all the links have /undefined/ in the url, which is visible in the status bar when I hold the mouse over the link. This happens for every single link in the wiki.

undefined

This setup is an old laptop:

WardCunningham commented 7 years ago

I suspect that my problem is in this line of code:

https://github.com/WardCunningham/remodeling/blob/master/static/index.html#L131

I chose to construct links this way because it worked for me in a variety of hosting situations. I can probably rewrite this in a way that will work for your version of firefox but I would like to confirm that this is the problem first.

Can you check for me what values are return for location.origin and location.pathname when visiting a correctly rendered version of a wiki page? Here is what I get on my version of firefox (50.0.2).

screen shot 2016-12-17 at 12 15 53 pm

WardCunningham commented 7 years ago

Peter replies:

Seems you're right - location.origin is undefined. Apparently it was added in Firefox 21 according to this document:

https://developer.mozilla.org/en-US/docs/Web/API/Window/location

Therefore, pre-21.0 versions of Firefox will render the wiki incorrectly. Other browsers that do not support location.origin:

This may be relevant:

if (!window.location.origin) {
  // Some browsers (mainly IE) does not
  // have this property, so we need to build it manually...
  window.location.origin = window.location.protocol + '//' +
    window.location.hostname +
    (window.location.port ? (':' + window.location.port) : '');
}
WardCunningham commented 7 years ago

Peter reports that the remodeled wiki now works in his environment.

We understand that many web developers live in an economy that rewards maximal backward compatibility and are willing to jump through hoops to that end. In this case Peter did the hoop jumping with specific motivation that he explained to me. Even more important to me, the fix did not require exotic dependencies or build processes prone to breakage in the future.