-
Notifications
You must be signed in to change notification settings - Fork 198
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/session-delegate #160
Open
lhunath
wants to merge
7
commits into
LeonardoCardoso:main
Choose a base branch
from
lhunath:fix/session-delegate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix/session-delegate #160
Conversation
This file contains 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
…RegexLimit update Regex.swift. Upgrade regex limit length
When an image URL is not an absolute URL (ie. protocol://url), we want to put the base URL in front of it, if it is known. BUT, if neither the base URL ends in / or the image URL start with /, the current formatImageURL mashes them together without a slash, leading to something like https://base.comimages/image.jpg
SwiftLinkPreview's public API is one that asks the user for a URLSession. This API gives the user the freedom to fully configure their own URLSession (such as by setting a custom delegate) as well as giving them control over invalidating the session through finishTasksAndInvalidate() or invalidateAndCancel(). Internally, however, at some point SwiftLinkPreview re-creates the URLSession in order to set its own delegate. This is bad form because it belies the public API, resulting in behaviour that violates its own contract: now the URLSession that was given to it no longer honours the user's URLSessionDelegate and it ignores invalidation calls. Either SwiftLinkPreview should have a public API that *only* asks for a URLSessionConfiguration and then make its own URLSessions off that, or it should ask for a URLSession and then honour that contract without internally changing the actual session used. This solution does the latter. Note that SwiftLinkPreview's replacement delegate appears to be purely to ensure redirects are happening, but this is already the automatic behaviour for background-style URLSessions (which are probably the type you want to use with SwiftLinkPreview anyway). If the user wants redirects without a background-style URLSession, he should handle that in his own URLSession. Note that the behaviour of URLSession is 100% out-of-scope for SwiftLinkPreview, especially when SwiftLinkPreview is asking the user for what session to use.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed f84740e
SwiftLinkPreview destroys and recreates the
URLSession
, causing the user to lose control over the session he gave to SwiftLinkPreview (ie. his delegate will stop working & his session invalidation will be ignored).