fix: handle upper case protocol like HTTP or HTTPS by FDrag0n · Pull Request #1805 · koajs/koa (original) (raw)

@FDrag0n

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

@FDrag0n

fix pull 1804 when url like HTTP or HTTPS

@FDrag0n

fix pull 1804 when url like HTTP or HTTPS

@codecov

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

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

@fengmk2 fengmk2 changed the titlefix pull 1804 when url like HTTP or HTTPS fix: support upper case protocol like HTTP or HTTPS

Mar 21, 2024

@fengmk2 fengmk2 changed the titlefix: support upper case protocol like HTTP or HTTPS fix: handle upper case protocol like HTTP or HTTPS

Mar 21, 2024

@fengmk2

fengmk2

// location
if (url === 'back') url = this.ctx.get('Referrer') | alt
if (url.startsWith('https://') | url.startsWith('http://')) {
if (/^https?:\/\//i.test(url)) {

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.

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 added a commit that referenced this pull request

Mar 21, 2024

@FDrag0n @fengmk2

Co-authored-by: fengmk2 suqian.yf@antgroup.com

fengmk2 added a commit that referenced this pull request

Mar 21, 2024

@fengmk2 @FDrag0n

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})