Skip to content

Commit

Permalink
And direct path for schema not changing. (#379)
Browse files Browse the repository at this point in the history
To simplify the flow a little but also avoid doing any work in cases where the
redirect doesn't change the scheme, and an explicit path for that in the
redirection validations.
  • Loading branch information
thomasvl committed Feb 12, 2024
1 parent 79653ec commit 42ed23d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Core/GTMSessionFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,14 @@ + (nullable NSURL *)redirectURLWithOriginalRequestURL:(nullable NSURL *)original

NSString *originalScheme = originalRequestURL.scheme;
NSString *redirectScheme = redirectRequestURL.scheme;

// If no change in scheme with redirect, just return the redirect.
if (originalScheme != nil &&
redirectScheme != nil &&
[originalScheme caseInsensitiveCompare:redirectScheme] == NSOrderedSame) {
return redirectRequestURL;
}

BOOL insecureToSecureRedirect =
(originalScheme != nil && [originalScheme caseInsensitiveCompare:@"http"] == NSOrderedSame &&
redirectScheme != nil && [redirectScheme caseInsensitiveCompare:@"https"] == NSOrderedSame);
Expand Down

0 comments on commit 42ed23d

Please sign in to comment.