-
Notifications
You must be signed in to change notification settings - Fork 442
Ref #1533 - Set location view text field to scheme-less domain url #1628
Ref #1533 - Set location view text field to scheme-less domain url #1628
Conversation
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.
Thanks for the contribution, the code works well :)
I'm adding blocked
label, waiting on final decision from the product team
@@ -321,7 +321,7 @@ class TabLocationView: UIView { | |||
|
|||
fileprivate func updateTextWithURL() { | |||
(urlTextField as? DisplayTextField)?.hostString = url?.host ?? "" | |||
urlTextField.text = url?.schemelessAbsoluteString.trim("/") | |||
urlTextField.text = url?.domainURL.schemelessAbsoluteString.trim("/") |
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 domainURL
strips m.
and mobile.
schemes as well.
I talked to security team and they want to hide scheme only with www.
case.
So one additional helper method needs to be added to URLExtensions.swift
to remove only the www
part
…ile host property
@iccub I've pushed an update for the requested change. Please let me know if you have any suggestions for improvement. |
* E.g., https://m.foo.com/bar/baz?noo=abc#123 => https://m.foo.com/ | ||
* Or https://mobile.foo.com/bar/baz?noo=abc#123 => https://mobile.foo.com/ | ||
*/ | ||
public var mobileDomainURL: URL { |
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.
All of this code is duplicated and the only difference is between "^(www)\\."
, "^(www|mobile|m)\\."
regexes
What do you think about some DRY refactor?
- change
domainURL
to a functionfunc domainURL(stripWWWSubdomainOnly: Bool = false) -> URL
- same for
normalizedHost
- in
normalizedHost
add something likelet regex = stripWWWSubdomainOnly ? "^(www)\\." : "^(www|mobile|m)\\."
- update documentation comment in
domainURL
- update
testdomainURL
unit test
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.
Great suggestions! I've made the requested changes and added a new unit test to account for the stripWWWSubdomainOnly
parameter.
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.
Great stuff, thanks :)
Just needs a rebase and we are good |
conflicts resolved :) |
CI still failing with
|
Summary of Changes
This pull request fixes issue #1533
This change sets the
urlTextField
using thedomainURL
. Setting it here allows for the full url to still be accessible when the user taps into the location view.Submitter Checklist:
NSLocalizableString()
Test Plan:
Screenshots:
Shortened domainURL
Full url when location view tapped
Reviewer Checklist:
QA/(Yes|No)
release-notes/(include|exclude)
bug
/enhancement