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

fix: handle upper case protocol like HTTP or HTTPS #1805

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

FDrag0n
Copy link
Contributor

@FDrag0n FDrag0n commented Mar 21, 2024

#1800 's fix #1804 forgot to consider the case where url is uppercase HTTP and HTTPS

fix pull 1804 when url like HTTP or HTTPS
fix pull 1804 when url like HTTP or HTTPS
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.66%. Comparing base (435534a) to head (7f35d51).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1805   +/-   ##
=======================================
  Coverage   98.66%   98.66%           
=======================================
  Files           5        5           
  Lines         525      525           
  Branches      147      147           
=======================================
  Hits          518      518           
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FDrag0n
Copy link
Contributor Author

FDrag0n commented Mar 21, 2024

@fengmk2 I realized we forgot to deal with Case conversion of http in #1804 fix !

@fengmk2 fengmk2 changed the title fix pull 1804 when url like HTTP or HTTPS fix: support upper case protocol like HTTP or HTTPS Mar 21, 2024
@fengmk2 fengmk2 changed the title fix: support upper case protocol like HTTP or HTTPS fix: handle upper case protocol like HTTP or HTTPS Mar 21, 2024
@fengmk2 fengmk2 self-assigned this Mar 21, 2024
@fengmk2 fengmk2 added the bug label Mar 21, 2024
@@ -266,7 +266,7 @@ module.exports = {
redirect (url, alt) {
// location
if (url === 'back') url = this.ctx.get('Referrer') || alt || '/'
if (url.startsWith('https://') || url.startsWith('http://')) {
if (/^https?:\/\//i.test(url)) {
Copy link
Member

Choose a reason for hiding this comment

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

@FDrag0n I change to use Regex to avoid lowerCase twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a nice change👍

@fengmk2 fengmk2 merged commit 185e701 into koajs:master Mar 21, 2024
11 checks passed
fengmk2 added a commit that referenced this pull request Mar 21, 2024
Co-authored-by: fengmk2 <suqian.yf@antgroup.com>
fengmk2 added a commit that referenced this pull request Mar 21, 2024
pick from #1805

Co-authored-by: FDrag0n <34733637+FDrag0n@users.noreply.github.com>
etroynov pushed a commit to etroynov/koa that referenced this pull request Apr 1, 2024
Co-authored-by: fengmk2 <suqian.yf@antgroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants