Slashes at end of URLs
See original GitHub issueIs there a way to avoid the “/” characters getting added to my URLs?
In this sandbox, click on the /page1 or /page2 links and you will see the URL change to /page1/ or /page2/. Happens in my own app, too.
https://codesandbox.io/s/n7v5o7j310
All the code:
import React from "react";
import ReactDOM from "react-dom";
import { mount, route } from "navi";
import { Router, Link } from "react-navi";
import "./styles.css";
const routes = mount({
"/": route({
view: () => (
<p>
Home. Go to <Link href="/page1">page 1</Link> or{" "}
<Link href="/page2">page 2</Link>.
</p>
)
}),
"/page1": route({
view: () => (
<p>
Page 1. Go <Link href="/">home</Link> or to{" "}
<Link href="/page2">page 2</Link>.
</p>
)
}),
"/page2": route({
view: () => (
<p>
Page 2. Go <Link href="/">home</Link> or to{" "}
<Link href="/page1">page 1</Link>.
</p>
)
})
});
function App() {
return (
<div className="App">
<Router routes={routes} />
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
When should I use a trailing slash in my URL? - Stack Overflow
A slash at the end of the URL makes the address look "pretty". A URL without a slash at the end and without...
Read more >Should You Have a Trailing Slash at the End of URLs?
The trailing slash matters for most URLs. Conventionally, a trailing slash (/) at the end of a URL meant that the URL was...
Read more >To slash or not to slash | Google Search Central Blog
This behavior is beneficial because it reduces duplicate content. In the particular case of redirects to trailing slash URLs, our search results will...
Read more >Trailing Slashes and SEO - Best Practice Guide - Safari Digital
Historically, a trailing slash marked a directory and a URL without a trailing slash at the end used to mean that the URL...
Read more >Trailing Slashes in URLs – What is the Preferred Style?
The addition of a slash at the end of a URL instructs the web server to search for a directory. This speeds the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was getting
Error: Not implemented: window.scroll
. Just for the boilerplate create-react-app “App doesn’t crash” type test. I have a test setup file that jest loads. It has a global.window variable to handle this and like session storage. I don’t know of a better solution than this but I got rid of that error @jdiamond by doing this. Jest runs without errors but I just got this working.Maybe your project is slightly different, maybe this helps. 🎈
We code in javascript, nothing horrifies us anymore. =)