Skip to content
New issue

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

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

Already on GitHub? # to your account

perfixLink should add any required trailing slashes #855

Closed
danielo515 opened this issue Apr 25, 2017 · 4 comments
Closed

perfixLink should add any required trailing slashes #855

danielo515 opened this issue Apr 25, 2017 · 4 comments

Comments

@danielo515
Copy link

Hello,

I expect the helper function prefixLink to generate valid links, no matter what I throw to it.

For example, I expect the following to work

 <Link to={prefixLink('somesection')}>
                           BlaBLa
   </Link>

But it does not. I'm forced to do it like this:

 <Link to={prefixLink('somesection/')}>
                           BlaBLa
   </Link>

Please note the trailinig / at the end of somesection
Not a big deal, but a bit annoying. I didn't noticed this before because 99% of my links are generated automatically from gatsby metadata.

@KyleAMathews
Copy link
Contributor

What does it create that's invalid?

The code is pretty simple, feel free to make a PR to fix up things! https://github.com/gatsbyjs/gatsby/blob/master/lib/isomorphic/gatsby-helpers.js#L33

@emilyaviva
Copy link
Contributor

emilyaviva commented Apr 25, 2017

I actually think this should stay the way it is. Outside of webpack-dev-server, postfixing a / to a link may not actually be what you want in a production environment. The prefixLink function should hew literally to the string that's passed to it literally as an argument.

@KyleAMathews
Copy link
Contributor

Oh good point. Yeah, trailing slashes aren't required. Technically you could have pages at both the slashless and with-it versions (though that'd be really confusing). Perhaps what prefixLink could do though is tell you when you try linking to a page that doesn't exist.

@jbolda jbolda added the v0 label Jun 5, 2017
@KyleAMathews
Copy link
Contributor

Closed as not support v0 anymore

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

No branches or pull requests

4 participants