Skip to content
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

Handle basePath without trailing slash #1344

Merged
merged 3 commits into from
Jan 7, 2020

Conversation

ShazzAmin
Copy link
Contributor

@ShazzAmin ShazzAmin commented Nov 26, 2019

Description

The documentation states that the basePath configuration can be used to host a site at a specified path, e.g. https://mysite.com/blog. However, the regular expression we use doesn't catch /blog, only /blog/*.

Changes/Tasks

  • Made the path /{basePath} resolve to / when determining the route path.

Motivation and Context

Allows sites hosted at a particular path to function as expected and as described in existing documentation.

Types of changes

  • Refactoring/add tests (refactoring or adding test which isn't a fix or add a feature)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have updated the documentation accordingly
  • I have updated the CHANGELOG with a summary of my changes
  • My changes have tests around them

@SleeplessByte
Copy link
Member

However, the regular expression we use doesn't catch /blog, only /blog/*.

Do you meant that you don't want an index page by react-static? I don't quite understand what the issue is 😓

@ShazzAmin
Copy link
Contributor Author

However, the regular expression we use doesn't catch /blog, only /blog/*.

Do you meant that you don't want an index page by react-static? I don't quite understand what the issue is 😓

Let's say I am using react-static to host a blog on my website which is on the domain example.com. I want my blog to be available at example.com/blog. So, in react-static's configuration, I set basePath to be blog.

If a user visits my blog at example.com/blog, react-static should internally rewrite the /blog to / and serve the user whatever is at that route. The problem is that the rewrite function does not currently rewrite /blog to / (see this test). It does rewrite blog, blog/ and /blog/ to / (see the rest of the tests in that diff). This looks like a bug to me. Let me know if I've misunderstood something and/or if this behaviour is intentional.

@SleeplessByte
Copy link
Member

SleeplessByte commented Dec 19, 2019 via email

Copy link
Member

@SleeplessByte SleeplessByte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just get this merged and see if there are reports coming in.

@SleeplessByte SleeplessByte merged commit a7bad8a into react-static:master Jan 7, 2020
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 this pull request may close these issues.

2 participants