Skip to content
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

Validate .tld for new feed URLs #325

Merged
merged 3 commits into from
Nov 25, 2015

Conversation

blowery
Copy link
Contributor

@blowery blowery commented Nov 20, 2015

Ensure that new feed URLs have a valid .tld before allowing the user to follow the feed.

dfbc6e9c-8eb5-11e5-8bec-c09eb793c6cd

Fixes #96.

@bluefuton
Copy link
Contributor

@artpi had concerns over using the parse-domain library, because it has this list hard-coded:
https://github.com/peerigon/parse-domain/blob/master/lib/tld.js

We could perhaps swap it out for a simple check if looks like a .tld (i.e. a dot and at least 2 characters at the end of the string).

@bluefuton bluefuton force-pushed the fix/reader-following-management-tld-validation branch from 73d245c to 973657d Compare November 24, 2015 11:47
@bluefuton bluefuton added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Nov 24, 2015
@bluefuton
Copy link
Contributor

cc @aerych

}

return false;
// Check for a valid-looking TLD
const lastHostnameSegment = last( parsedUrl.hostname.split( '.' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is fine, but you could also use lastIndexOf, compare that to length - 2 (3?), and avoid the allocations that come with split.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like that. Changing now.

@blowery blowery added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 25, 2015
@blowery
Copy link
Contributor Author

blowery commented Nov 25, 2015

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants