-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Twingly::URL#ttld, "true TLD" getter #88
Conversation
Many[1] ccTLDs have introduced a second level underneath their ccTLD, but often, we don't care about the second level. We want the "true TLD". Discussed in https://github.com/twingly/wally/issues/49. [1]: https://en.wikipedia.org/wiki/Second-level_domain
@@ -35,6 +35,11 @@ | |||
it { is_expected.to eq("") } | |||
end | |||
|
|||
describe "#ttld" do | |||
subject { url.tld } |
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.
tld -> ttld
Could |
Don't think it helps, still an ambiguous name that you need to "learn". Might be easier to differentiate from |
Sure, we can keep it as |
@@ -100,6 +100,10 @@ def tld | |||
public_suffix_domain.tld | |||
end | |||
|
|||
def ttld |
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.
Maybe a comment why we call it ttld
?
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.
What would the comment say? Wouldn't it be better to call the method true_tld
then?
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.
@jage Like this?
# Many ccTLDs have a second level[1] underneath their ccTLD, use this when
# you don't care about the second level.
#
# [1]: https://en.wikipedia.org/wiki/Second-level_domain
def ttld
tld.split(".").last
end
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.
What would the comment say? Wouldn't it be better to call the method true_tld then?
Nah, I don't think true is any better. "True" doesn't add any context when to use this.
@jage Like this?
Yes, that's better.
Just #88 (comment), otherwise this LGTM! |
@@ -171,6 +171,11 @@ def valid_urls | |||
it { is_expected.to eq("co.uk") } | |||
end | |||
|
|||
describe "#ttld" do | |||
subject { url.ttld } | |||
it { is_expected.to eq("uk") } |
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.
Maybe me being a 🐔 but I think I'd like a test for #ttld
when we have a normal domain as well, like a simple .com
. I am thinking to expose problems in the way we split the #tld
.
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.
Sure
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.
LGTM! |
Many1 ccTLDs have introduced a second level underneath their ccTLD, but
often, we don't care about the second level. We want the "true TLD".
Discussed in https://github.com/twingly/wally/issues/49.