Comments (6)
A bit of research
- ~60 SLD-enabled TLDs according to List of TLDs
- example SLDs: *.uk, *.tz, *.br
- Mozilla maintained list of "public suffixes" (readme) that are not maintained by their individual NIC (wtf?)
- List of Second Level Domains (SLD) (via randomtype) - currently knowing 1400 SLDs (wtf?)
still unclear
is every SLD-enabled TLD prohibiting 'foo.uk' in favor of 'foo.co.uk' or are SLD (sometimes?) only a suggestion? If there's a black 'n white "doing SLD completely or not at all", we might inverse the process to scanning for TLDs not enabling SLDs (~150 vs 1400). But then "virtual TLDs" (e.g. ''.dev' used by me for local development infrastructure) wouldn't apply anymore. So, pretty much not an option (for me) either. damn.
I'm certain I can convert that list of SLDs to some regexp and hook that into .domain()
and .tld()
. I'm not yet sure if I want to "break" current behavior, though. .tld()
currently returns 'uk' for 'foo.co.uk' which may very well be what the implementor expected. If it were to return 'co.uk', how would the 'uk' part be accessed? The alternative would be adding new methods, which is not quite the way to go (for me) either.
I'll have to think about this some more…
from uri.js.
@ul1994 I cloned that to #333, fixed the problem and released v1.18.10
from uri.js.
I see your point. I must admit that I haven't thought about these xx.tld domains at all. Unless there is a table of second-level-domains (xx.tld), I wouldn't know how to make this happen. (subdomain.db.de
here db.de
is the actual domain.)
If anyone has any pointers, please let me know.
from uri.js.
Second Level Domains are now properly handled by URI.js Version 1.5.0
var uri = URI("http://www.example.co.uk")
uri.domain() // returns "example.co.uk"
uri.domain(true) // returns "co.uk"
uri.tld() // returns "co.uk"
uri.tld(true) // returns "uk"
uri.tld("co.il") // allowed, since it's a known SLD
uri.tld("foo.bar") // setting TLD to "bar" since "foo.bar" is unknown
src/SecondLevelDomains.js
contains a list of SLDs (imported from Gaving Miller's Second Level Domains List as well as some regular expressions for testing. This file needs to be loaded (before URI.js) to enable Second Level Domain support.
I hope this helps…
from uri.js.
works as expected, i.e. this is awesome! Thanks alot for looking into it!
from uri.js.
Felt I should post this here since I've run into a similar issue.
const uri = require('urijs');
const a = new uri('http://torrentz.eu.com');
console.log(a.domain());
The above code outputs eu.com
, but I believe the correct result here should be torrentz.eu.com
. What would it take to output the expected domain?
from uri.js.
Related Issues (20)
- Different results between 1.19.1 and 1.19.2 when using uri.scheme HOT 4
- What is the point of directory, suffix, etc? HOT 2
- Support for handling search as ES6 Map instead of Object properties
- setSearch() breaks previous url parameters
- Property for File Name without File Extension
- A reference resolution does not match RFC3986
- Test if URI/URL is templated
- URI.min.js 1.19.4 throws "does not have either property: href, src, action, cite" HOT 2
- [Feature request] Support for nested objects inside template builder.
- Hope to join the 'filenameNoExtension' api
- directory function is prepending not appending
- Append segments
- Trying to get in touch with you regarding a security issue HOT 1
- Handling of relative URLs that have a protocol in latest 1.19.7 HOT 1
- @types/urijs/index can only be default-imported using the 'allowSyntheticDefaultImports' flag HOT 1
- charset=Shift_JIS will fail to parse URI.js with a syntax error caused by non-ASCII characters in RegExp HOT 2
- Make invalid port check optional to support url templates
- Can we change separator?
- URI malformed exception is thrown when overriding path/pathname HOT 1
- Please do not omit the file extension for the value of the "main" field in the package.json
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 uri.js.