Skip to content

Commit

Permalink
Fix: don't forward auth headers to different protocol (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtripg6666tdr authored Jan 30, 2023
1 parent a53eee2 commit 36d7fe7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type destroyable = {destroyed?:boolean, destroy:()=>void};
const destroy = (...destroyable:destroyable[]) => destroyable.map(stream => {
if(!stream.destroyed) stream.destroy();
});
const normalizeKey = (key:string) => key.split("-").map(e => [e[0].toUpperCase(), e.slice(1).toLowerCase()].join("")).join("-");
const normalizeKey = (key:string) => key.split("-").map(e => e[0].toUpperCase() + e.slice(1).toLowerCase()).join("-");

/**
* Represents candyget's result type.
Expand Down Expand Up @@ -364,7 +364,7 @@ function candyget<T extends keyof BodyTypes, U>(urlOrMethod:Url|HttpMethods, ret
const originalUrl = url;
const executeRequest = (requestUrl:URL) => {
if(redirectCount > 0){
if(originalUrl.host !== requestUrl.host){
if(originalUrl.host !== requestUrl.host || originalUrl.protocol !== requestUrl.protocol){
// delete credentials to prevent from leaking credentials
delete options.headers["Cookie"];
delete options.headers["Authorization"];
Expand Down

0 comments on commit 36d7fe7

Please sign in to comment.