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

[now-routing-utils] Change behavior of trailingSlash: true redirects #3745

Merged
merged 8 commits into from Feb 6, 2020

Conversation

styfle
Copy link
Member

@styfle styfle commented Feb 5, 2020

This PR changes the behavior of trailingSlash: true after we received feedback that files should not be redirected with a trailing slash. This matches the behavior of serve and serve-handler.

Examples

  • /index.html => serve
  • /assets/style.css => serve
  • /assets => redirect to /assets/
  • /assets/style => redirect to /assets/style/

Additional

In order to avoid duplicate content, this PR also adds redirects to files without a trailing slash.

  • /about.html/ => redirect to /about.html
  • /assets/style.css/ => redirect to /assets/style.css

Fixes #3731

Copy link
Contributor

@dav-is dav-is left a comment

Choose a reason for hiding this comment

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

Amazing work 🙌

@TooTallNate
Copy link
Member

Seems like the now dev tests are failing:

  ✖ [now dev] test trailingSlash true serve correct content Rejected promise returned by test

  1 test failed

  [now dev] test trailingSlash true serve correct content

  /Users/runner/runners/2.164.0/work/now/now/packages/now-cli/test/dev/integration.js:144

   143:     const actualText = await res.text();              
   144:     t.is(actualText.trim(), expectedText.trim(), msg);
   145:   }                                                   

  Rejected promise returned by test. Reason:

  TypeError {
    message: 'expectedText.trim is not a function',
  }

@styfle
Copy link
Member Author

styfle commented Feb 5, 2020

@TooTallNate I forgot a parameter in the tests 🤦‍♂

(if our tests used typescript it would have caught that mistake 😄 )

@styfle styfle merged commit adf31c3 into master Feb 6, 2020
@styfle styfle deleted the PRODUCT-341/trailing-slash-file-ext branch February 6, 2020 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trailingSlash feature parity between now and serve
3 participants