Comments (14)
This is a tricky one, may leave this for a separate "heavyweight" version.
from js-url.
This is a pretty big deal.
Take a peek at suffix.js for a solution. It's not as pretty as what you have though.
from js-url.
👍
Most browsers uses the list at http://publicsuffix.org/
from js-url.
New to this project, but quite interested so thought I'd contribute some thoughts.
waawii: Thanks for the publicsuffix.org link.
nelix: The simple approach of including all relevant TLDs would add 94KB, if we converted publicsuffix to a Javascript array. That's only 29KB after gzip, but it does somewhat weaken the lightweight aspect.
The first optimization that comes to mind would be to store the TLDs in a hierarchy, but the space saving is probably not too significant (will report back on this if I get a spare half hour).
[..., "uk", "mil.uk", "ac.uk", ...]
VS
[..., "uk": ["mil", "ac"], ...]
from js-url.
I have a solution that only works for the current url, not any arbitrary url. It exploits the fact that browsers can't set cookies for TLDs. I try to set a cookie until I can and that's the host
. From there you can easily infer the sub
and tld
https://gist.github.com/3043239
It only works for the current url because of course you can't set cookies for third party domains so you can't use this method.
from js-url.
This is a pretty big deal.
+1
from js-url.
https://github.com/oncletom/tld.js
Handful API to do stuff with domain names and URIs: validity, public etc.
Its main purpose is to check if a domain name is valid upon. 2 constraints:
an up-to-date TLDs database
must work in node.js and the browser
It is based on the public suffix list provided by Mozilla. Thanks Mozilla!
from js-url.
Hey, Is there a generic solution for this issue?
$.url("domain","http://www.rest.co.il/sites/Default.asp?txtRestID=15455");
outputs: "co.il"
instead of "rest.co.il"
.
from js-url.
outputs: "co.il" instead of "rest.co.il"
That's the expected result, I don't see co.il
in the public suffix list.
from js-url.
Hmm.. How is .co.il not in the public suffix list and .co.uk, for example, is? Both are second level domains, what's the difference?
from js-url.
Sorry, you are right, I just realize there is this entry: *.il
, which confirms that indeed co.il
should be seen as an effective TLD (I was searching for co.il
specifically). I made a library which would return you the proper result: https://github.com/gorhill/publicsuffixlist.js (you need to feed it the list though).
from js-url.
@websanova, are you planning to handle this issue? do you care to integrate your library with tld.js or publicsuffixlist.js (from the earlier comments), they both handle the country specific tlds? Thanks for the wonderful url parser library..
from js-url.
I'm currently preoccupied with work and a side project now so don't have
too much time to look into it. However would be good to make it some kind
of optional include if anyone is interested in integrating.
On May 13, 2015 09:31, "Sreekanth S" [email protected] wrote:
@websanova https://github.com/websanova, are you planning to handle
this issue? do you care to integrate your library with tld.js or
publicsuffixlist.js (from the earlier comments), they both handle the
country specific tlds? Thanks for the wonderful url parser library..—
Reply to this email directly or view it on GitHub
#3 (comment).
from js-url.
Added support for this. Comes in two versions now url-tld.min.js
and url.min.js
. The tld version is about twice the size since it contains a hard coded list of tld's. Not sure if it contains all of them, as I just copy and paste this off stackoverflow. Let me know if any are missing and I will add them.
from js-url.
Related Issues (20)
- TLD list needs to be updated! HOT 3
- Add AMD support HOT 1
- grunt-contrib-* should be put into devDependencies HOT 13
- if # is before ?, it won't parse ? prameter HOT 1
- .NET NuGet Package HOT 2
- path don't return trailing slash HOT 1
- Do not parse URLs with # HOT 1
- url('?poo'); // null should be -> undefined HOT 1
- mailto query string does not get parsed HOT 2
- domain is wrong HOT 1
- some domains is not defined HOT 7
- domain parse error HOT 1
- domain undefined HOT 1
- Domain parsing error
- Issues parsing arguments that are arrays with non-numeric keys
- Issues parsing array arguments? HOT 2
- Issues parsing multidimensional array arguments
- fileext returns wrong extention for names with a dot HOT 1
- Works incorrect in case of using wiredep grunt task HOT 4
- How to get in touch regarding a security concern
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-url.