-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SR-9887] HTTPCookie on Linux does not accept Substring values #2022
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
Conversation
@swift-ci test |
Foundation/HTTPCookie.swift
Outdated
if let str = strVal as? String { | ||
return str | ||
} else if let subStr = strVal as? Substring { | ||
return String(_: subStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be String(subStr)
Foundation/HTTPCookie.swift
Outdated
@@ -377,6 +377,15 @@ open class HTTPCookie : NSObject { | |||
} | |||
} | |||
|
|||
private class func getStringValue(strVal: Any?) -> String? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three suggestions here:
- Though this function name serves the purpose, we could shorten it, may be something like
stringValue
. Just a suggestion :) - Could this function be nested inside the initialiser where it is being used?
- Because we only seem to be adding support for Substrings, do we really need the
strVal as? String
check?
dc54a7a
to
24070d6
Compare
@swift-ci test |
1 similar comment
@swift-ci test |
Foundation/HTTPCookie.swift
Outdated
@@ -377,6 +377,15 @@ open class HTTPCookie : NSObject { | |||
} | |||
} | |||
|
|||
private class func getStringValue(strVal: Any?) -> String? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the method signature would read better if it is updated something like this getStringValue(_ strValue: Any?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the words StringValue in the method name and the strVal
parameter label reads redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ..thanks
@swift-ci test |
The HTTPCookie initializer takes values as
Any
but fails to create cookie when Substring is passed to it. Casting fromSubstring
to String returnsnil
due to which the initializer is failing silently.