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.

Add option to remove trailing slashes, as opposed to adding them

See original GitHub issue

Hello!

We’re serving a website through Gatsby, which is having some trouble removing trailing slashes when serving an index.html file.

As you can see from the PR and discussion, it seems to be impossible through configuration options to remove the trailing slash, even if it’s possible to stop from redirecting to a trailing slash.

Would you be interested in a PR which adds (or changes) an option to remove trailing slashes when serving index files?

Thank you very much 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dougwilsoncommented, Feb 4, 2020

The problem with links is mostly benign, I think. I haven’t seen a relative link in the wild in years. Either way, if you’re setting an option to remove trailing slashes you should understand the consequences.

You’d be surprised 😃 I am constantly helping new web programmers with little to no understanding of any of this, and would expect it to look the same way as when they double-click on the file on their file system.

I don’t think having the option you propose would be valid for this project now that I better understand it, I’m sorry. You’re welcome to use a different project or similar if that is really what you want to do without having a file system layout that matches the files served. But in reality, files should never be served up by Node.js unless as a last resort, so you should be using Apache/NGINX/etc. I’m not sure if they have those options you’re looking for, either, but if they do, that would probably be the best overall solution.

0reactions
dougwilsoncommented, Oct 12, 2020

Hi @formulahunter this is a general Node.js question I would suggest asking on Node.js itself to get the full answer. The short answer is that serving files will consume your worker pool (https://nodejs.org/en/docs/guides/dont-block-the-event-loop/).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >
How to edit trailing slashes in WordPress permalinks?
Permalink Manager may be a useful solution to modify trailing slashes settings if you do not have any technical skills or simply do...
Read more >
What is the simplest way to remove a trailing slash from each ...
The accepted answer will trim ONE trailing slash. One way to trim multiple trailing slashes is like this:
Read more >
Trailing Slash: What Is It In a URL? And Should You Have It
Go to Settings > Permalinks. Click on “Post Name” to automatically add trailing slashes to URLs and set up a proper 301 redirect....
Read more >
trailingslashit() | Function - WordPress Developer Resources
Will remove trailing forward and backslashes if it exists already before adding a trailing forward slash. This prevents double slashing a ...
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