linkinator icon indicating copy to clipboard operation
linkinator copied to clipboard

bug: path without trailing slash gets 404 error for relative links on page

Open sashasushko opened this issue 3 years ago • 2 comments

In continuation of the conversation https://github.com/JustinBeckwith/linkinator/issues/34#issuecomment-499075791


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
}

I think the problem is that the Linkinator is cutting end part of path for relative links before concat it with relative href:

https://neon.tech/docs/reference/api-reference > https://neon.tech/docs/reference/ > https://neon.tech/docs/reference/ + ../../manage/api-keys = https://neon.tech/manage/api-keys

sashasushko avatar Dec 14 '22 15:12 sashasushko

+1, also happens here.

Example:

  • https://engine.needle.tools/samples-uploads/pencil-sword (logs missing links with incorrect links)
  • https://engine.needle.tools/samples-uploads/pencil-sword/ (works fine)

hybridherbst avatar Feb 26 '24 12:02 hybridherbst

@JustinBeckwith mind taking a look? :)

hybridherbst avatar Feb 26 '24 12:02 hybridherbst