Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 1.16 KB

README.md

File metadata and controls

44 lines (36 loc) · 1.16 KB

Get SLD (second level domain)

get the SLD (second level domain) of a URL

Usage

download the JAR file from lib/Hostname-1.0-SNAPSHOT.jar and add it in your project.

String host = Hostname.getHostname("https://www.example.com");
How to add it to maven pom.xml?
<dependency>
    <groupId>com.github.HasanMhdAmin</groupId>
    <artifactId>Hostname</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/Hostname-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<!--...-->
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>

Sample

suppose you have these URLs:

The output to be only the host name, in the previous example the result for all domains should be example.

Author

Hasan Mhd Amin on GitHub @HasanMhdAmin