Jesus, NO! This is what's wrong with development today. This is equivalent to killing a fly with a Sherman tank.
Please, please, for the love of God and companies everywhere that are sick of obfuscated, confusing unmanageable, unmaintainable and insecure code, please look at the one line pure Javascript code above this answer.
There is absolutely no reason on earth to include a library with hundreds of lines of code to perform a simple operation.
Your comment is what's wrong with development today. Taking the shortest solution that seems to somehow solve the vague requirements and declaring it solved and secure.
Each of the JS solutions will fail for one of these test URLs: 'a.b.c.ac.il/', 'news.com.au/', 'youtube.com'.
Except for mine.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Javascript, using npm package "tldjs"
Try it: codesandbox.io/s/affectionate-dawn...
Jesus, NO! This is what's wrong with development today. This is equivalent to killing a fly with a Sherman tank.
Please, please, for the love of God and companies everywhere that are sick of obfuscated, confusing unmanageable, unmaintainable and insecure code, please look at the one line pure Javascript code above this answer.
There is absolutely no reason on earth to include a library with hundreds of lines of code to perform a simple operation.
Your comment is what's wrong with development today. Taking the shortest solution that seems to somehow solve the vague requirements and declaring it solved and secure.
Each of the JS solutions will fail for one of these test URLs: 'a.b.c.ac.il/', 'news.com.au/', 'youtube.com'.
Except for mine.