canonicalHostName

fun canonicalHostName(): String(source)

Returns value in its canonicalized hostname form

e.g.

"127.0.0.1"
    .toIPAddressV4()
    .canonicalHostName()
    .let { println(it) }
// 127.0.0.1

"::1"
    .toIPAddressV6()
    .canonicalHostName()
    .let { println(it) }
// [0:0:0:0:0:0:0:1]

"http://127.0.0.1:8081/path"
    .toIPSocketAddress()
    .canonicalHostName()
    .let { println(it) }
// 127.0.0.1

"http://[::1%1]:8081/path"
    .toIPSocketAddress()
    .canonicalHostName()
    .let { println(it) }
// [0:0:0:0:0:0:0:1%1]

"2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid"
    .toOnionAddressV3()
    .canonicalHostName()
    .let { println(it) }
// 2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion

LocalHost.IPv4
    .canonicalHostName()
    .let { println(it) }
// localhost