티스토리 뷰
728x90
https://stackoverflow.com/questions/9607903/get-domain-name-from-given-url/72678203#72678203
Get domain name from given url
Given a URL, I want to extract domain name(It should not include 'www' part). Url can contain http/https. Here is the java code that I wrote. Though It seems to work fine, is there any better appro...
stackoverflow.com
const val WWW = "www."
fun URL.domain(): String {
val domain: String = this.host
return if (domain.startsWith(ConstUtils.WWW)) {
domain.substring(ConstUtils.WWW.length)
} else {
domain
}
}
728x90
'공부' 카테고리의 다른 글
[ObjectMapper] How do I disable fail_on_empty_beans in Jackson? mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); (0) | 2022.06.20 |
---|---|
[Git] merge repositories (0) | 2022.06.20 |
[kotlin] URL.domain() (0) | 2022.06.20 |
[swagger] custom path, custom api-docs (0) | 2022.06.20 |
[gradle] custom path --settings-file ../package/settings.gradle.kts; custom sub modules (0) | 2022.06.20 |
[Shell] concat string arrays (0) | 2022.06.20 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- 142,691
- Today
- 17
- Yesterday
- 219
TAG
- wlw
- 클루지
- Kluge
- Bot
- 책그림
- 어떻게 능력을 보여줄 것인가?
- follower
- COUNT
- 메디파크 내과 전문의 의학박사 김영수
- 인스타그램
- 팔로워 수 세기
- 개리마커스
- 김달
- 유투브
- 연애학개론