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

feat: add decodeFullUrl option #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

P4sca1
Copy link

@P4sca1 P4sca1 commented Oct 17, 2019

Adds an option decodeFullUrl to also add protocol and host to the url.
This allows for http to https or www to non-www redirects for example.
README is also updated and contains a new example for using this option.

Also changes onDecode signature to (req, options) instead of (req, res, next), because options are useful when decoding the url but res and next are never used (and I couldn't find a use case).

Changes onDecode signature to (req, options) instead of (req, res, next), because options are useful when decoding the url but res and next are never used (and I couldn't find a usecase).
@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #57 into master will decrease coverage by 15.55%.
The diff coverage is 30.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##            master      #57       +/-   ##
============================================
- Coverage   100.00%   84.44%   -15.56%     
============================================
  Files            2        2               
  Lines           37       45        +8     
  Branches         8       13        +5     
============================================
+ Hits            37       38        +1     
- Misses           0        3        +3     
- Partials         0        4        +4     
Impacted Files Coverage Δ
lib/module.js 75.00% <22.22%> (-25.00%) ⬇️
lib/middleware.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4001371...1e1f121. Read the comment docs.

@manniL
Copy link
Member

manniL commented Oct 19, 2019

@P4sca1 could you update the tests as well please?

@P4sca1
Copy link
Author

P4sca1 commented Oct 19, 2019

Never done this before, could you give me some advices?
Also testing would require to change the decodeFullUrl option on a per test case basis. Currently the config is static. What would be the best way to do this? 2 Nuxt instances with different configs?

@manniL
Copy link
Member

manniL commented Oct 19, 2019

Sure!

The tests are in the repo. A way to change the config dynamically is shown @ https://github.com/nuxt-community/redirect-module/blob/master/test/module.test.js#L107-L114

But you could also use multiple fixtures as shown in e.g. https://github.com/nuxt-community/style-resources-module/tree/master/test/fixture

@P4sca1
Copy link
Author

P4sca1 commented Oct 6, 2020

@manniL I finally found some time to make myself a little bit familiar with jest.
I added a test for the new decodeFullUrl option.

@nelhop
Copy link

nelhop commented Jul 14, 2022

Nice feature, which I would love to use. What are the plans about merging this PR?

This also would fix #73

@manniL manniL self-requested a review July 14, 2022 12:05
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.

None yet

3 participants