Skip to content

Many relative links are broken (because Github Pages adds trailing slashes) #188

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

Closed
danieldiekmeier opened this issue Sep 30, 2023 · 1 comment · Fixed by #190
Closed

Comments

@danieldiekmeier
Copy link
Contributor

Hello! I recently submitted the PR #187 that fixed a few relative links on the website.

After, I wondered if there were any more. I checked out the repo, started middleman and ran broken-link-checker. I was surprised to find: It reported the exact links that I just fixed.

Indeed: Due to the fact that middleman does NOT add trailing slashes to paths, but Github Pages does, the website works perfectly fine in development, but not in production.

I installed Rack Rewrite and added this to the config.rb to sync the behaviour:

require 'rack/rewrite'

configure :development do
  use ::Rack::Rewrite do
    # add trailing slash, like Github Pages
    r301 %r{/features/(.*)}, '/features/$1/', not: %r{/$}
  end
end

I ran the broken-link-checker again, and this time, it found links that were really broken, around ~75. I think they all have the same problem, that don't account for the trailing slash.

I was wondering if it would make sense to fix these in a PR or not? I noticed that the markdown files basically mirror the files in the repo: https://github.com/rspec/rspec-rails/blob/main/features/controller_specs/README.md so I'd guess that it doesn't make sense to edit all the files here manually?

I'd be happy to help, but I think I need someone to point me in the right direction.

@pirj
Copy link
Member

pirj commented Oct 10, 2023

We use the umbrella rspec-dev repo to run a task that converts projects' gherkin to Markdown and puts it in this repo.
E.g. this doc that you've fixed is generated from this feature spec.

If this process results in broken links, next time we run this task will overwrite what you've manually fixed.
Do you think you know how to fix this?
Adding a broken link checker would be a very nice addition to our CI, which we don't really have in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants