Giter Site home page Giter Site logo

Comments (14)

websanova avatar websanova commented on July 29, 2024

This is a tricky one, may leave this for a separate "heavyweight" version.

from js-url.

nelix avatar nelix commented on July 29, 2024

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.

waawal avatar waawal commented on July 29, 2024

👍

Most browsers uses the list at http://publicsuffix.org/

from js-url.

46bit avatar 46bit commented on July 29, 2024

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.

eduardocereto avatar eduardocereto commented on July 29, 2024

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.

mattes avatar mattes commented on July 29, 2024

This is a pretty big deal.

+1

from js-url.

mattes avatar mattes commented on July 29, 2024

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.

origal avatar origal commented on July 29, 2024

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.

gorhill avatar gorhill commented on July 29, 2024

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.

origal avatar origal commented on July 29, 2024

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.

gorhill avatar gorhill commented on July 29, 2024

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.

ssreekanth avatar ssreekanth commented on July 29, 2024

@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.

websanova avatar websanova commented on July 29, 2024

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.

websanova avatar websanova commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.