Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative files issue #34

Closed
XhmikosR opened this issue Feb 16, 2019 · 10 comments · Fixed by #40 or #42
Closed

Relative files issue #34

XhmikosR opened this issue Feb 16, 2019 · 10 comments · Fixed by #40 or #42
Assignees
Labels
bug Something isn't working released

Comments

@XhmikosR
Copy link
Contributor

BTW It seems when a link is relative it wrongfully is detected as broken.

For example:

Scanning http://localhost:5180/docs/4.3/examples/navbar-static/
 [200] https://getbootstrap.com/docs/4.3/examples/navbar-static/
 [404] http://localhost:5180/navbar-top.css
 [200] http://localhost:5180/docs/4.3/examples/navbar-fixed/

navbar-top.css is linked in http://localhost:5180/docs/4.3/examples/navbar-static/ with <link href="navbar-top.css" rel="stylesheet">.

At first I thought it was a Windows specific issue but it seems it fails on Travis CI too: https://travis-ci.org/twbs/bootstrap/jobs/494265231#L1399

@JustinBeckwith
Copy link
Owner

🎉 This issue has been resolved in version 1.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@XhmikosR
Copy link
Contributor Author

Hey, @JustinBeckwith thanks for the quick patch! Unfortunately, it seems to still fail. :/

See https://travis-ci.org/twbs/bootstrap/jobs/494434529#L1443

@JustinBeckwith
Copy link
Owner

I'm like 99% sure we got it this time 😆 I ran it against the bootstrap generated docs just to make sure I'm not nutz, and everthing looks to work. Thanks for being patient!

@JustinBeckwith
Copy link
Owner

🎉 This issue has been resolved in version 1.1.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@XhmikosR
Copy link
Contributor Author

Yup, confirmed, thanks!

@meleyal
Copy link

meleyal commented Jun 5, 2019

It seems like this no longer works, I'm getting false positives for relative links (links starting with ../).

Update: It seems to fail for us on links without a trailing slash. Our site generator (middleman) generates an about-us/index.html file to support clean urls (about-us), but our internal links use a mix of both with and without trailing slashes. We serve the site with nginx, which adds the trailing slash by default (about-us/). This doesn't happen with serve-static, so links without a trailing slash resolve differently and cause the 404s.

Update 2: On testing, it looks like serve-static does append a trailing slash. The problem seems to be that gaxios doesn't respect the directory index when doing a GET/HEAD request.

PR Here: #71

@samdutton
Copy link

I get the following when running npx linkinator https://simpl.info --recurse --format CSV:

"https://simpl.info/video/chrome.mp4",404,BROKEN,"https://simpl.info/video",""
"https://simpl.info/video/chrome.webm",404,BROKEN,"https://simpl.info/video",""
"https://simpl.info/images/poster.jpg",404,BROKEN,"https://simpl.info/video",""

Here's the HTML:

<video autoplay controls playsinline poster="images/poster.jpg" preload="metadata">
  <source src="video/chrome.webm" type="video/webm" />
  <source src="video/chrome.mp4" type="video/mp4" />
  <p>This browser does not support the video element.</p>
</video>

I assume the 404 reported by Linkinator is because the source src and poster values are checked relative to the site root.

However, I get similar problems with npx linkinator https://simpl.info/video, and if I run npx linkinator . locally from the /video directory, the source src and poster values work OK, but I get a 404 for /images/icons/icon192.png (which Linkinator lists as "url": "images/icons/icon192.png" and likewise for an included CSS file.

In other words, I don't understand how to run Linkinator in a way that can handle relative (or root-relative) links.

@sashasushko
Copy link

@JustinBeckwith due #71 and message from @meleyal – I can give a practical example. We're using the Linkinator in our Neon docs.

On the page https://neon.tech/docs/reference/api-reference/ there are two relative links:
Снимок экрана 2022-12-13 в 08 36 05
Снимок экрана 2022-12-13 в 08 36 15

You can check, that them are perfectly working in browser. Also, these links are web-correct.

And when I'm checking this page by the Linkinator:

npm run check:broken-links -- https://neon.tech/docs/reference/api-reference

I'm getting errors:

{
  "links": [
    {
      "url": "https://neon.tech/manage/api-keys",
      "status": 404,
      "state": "BROKEN",
      "parent": "https://neon.tech/docs/reference/api-reference"
    },
    {
      "url": "https://neon.tech/manage/branches/",
      "status": 404,
      "state": "BROKEN",
      "parent": "https://neon.tech/docs/reference/api-reference"
    }
  ],
  "passed": false
}

But! If I'm passing to the Linkinator the same link with trailing slash:

npm run check:broken-links -- https://neon.tech/docs/reference/api-reference/

There are no errors:

{
  "links": [],
  "passed": true
}

@JustinBeckwith
Copy link
Owner

@sashasushko could I trouble you to open this as a new issue? Makes it much easier to make sure I get around to a fix!

@sashasushko
Copy link

@JustinBeckwith done – #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
5 participants