question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[new docs site] relative links on URLs with and without a trailing slash

See original GitHub issue

Environment

main branch, npm start in the docs directory.

What parser are you using?

Default (Espree)

What did you do?

Open USER GUIDE > Rules > no-cond-assign. Then, in the Related Rules section click no-extra-parens link.

What did you expect to happen?

To open no-extra-parens document.

What actually happened?

The link is broken as it points to rules/no-cond-assign/no-extra-parens.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

This is caused by writing rules/no-cond-assign.md to rules/no-cond-assign/index.html, unlike the current site where it is rules/no-cond-assign.html. The path on the new site is rules/no-cond-assign/ (with / at the end) as opposed to the current site where it is rules/no-cond-assign (without / at the end) so the relative links in the document are broken.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, May 24, 2022

link - https://new.eslint.org/docs/user-guide/getting-started/

On the current site, this page is https://eslint.org/docs/user-guide/getting-started (without trailing slash). Relative links on the page were set based on the URL without the trailing slash, and the current site redirects https://eslint.org/docs/user-guide/getting-started/ to https://eslint.org/docs/user-guide/getting-started, so it always works well.

On the new site, redirects don’t work, and with the trailing slash in https://new.eslint.org/docs/user-guide/getting-started/ relative links on the page are broken.

I have created a draft pr #15919. I would like to work on this. Can I find and fix the broken links?

I think we should decide on the approach first. Some ways to address this might be:

  1. Make redirects work on new.eslint.org/docs. I believe this would be ideal, but not sure if it is possible with Netlify’s proxying.
  2. Disable trailing slash redirects on docs-eslint.netlify.app so that it returns 404 on missing/extra trailing slash, if that’s possible on Netlify.
  3. Allow all URLs with and without a trailing slash, but use only domain-relative links (start with /) everywhere. It would probably be good to also decide for each page what would be its canonical URL, and generate rel="canonical" link tags and the sitemap accordingly.
0reactions
nzakascommented, Jun 23, 2022

Ooh, <base> seems like a good idea. Let’s try that: https://github.com/eslint/eslint/pull/16046

Alternate approach:

        if (!/(?:\/|\.html)$/.test(location.href)) {
            history.replaceState({}, "", location.href + "/");
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix trailing slash issues (depend on hosting provider) #3372
Another idea is to resolve all relative links at build time to absolute links, so that the presence of a trailing slash or...
Read more >
Relative links change if page called without trailing slash
However, any relative links within the page seem to think the page is one level higher when the page is called without the...
Read more >
Built relative URL in pages that are missing trailing slash
The reason we need to do this is because we need relative links to the current page. The CMS system that we are...
Read more >
To slash or not to slash | Google Search Central Blog
Historically, it's common for URLs with a trailing slash to indicate a directory, and those without a trailing slash to denote a file:....
Read more >
Trailing slashes on URLs: Contentious or settled?
It's a client-side thing, not a server-side thing. That is, if you have a resource (like an href to another page) in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found