How to use the hostname function from url

Find comprehensive JavaScript url.hostname code examples handpicked from public code repositorys.

166
167
168
169
170
171
172
173
174
175
// Prints https://example.com:82/foo
```

Invalid host values assigned to the `host` property are ignored.

#### url.hostname

* {string}

Gets and sets the hostname portion of the URL. The key difference between
fork icon19
star icon213
watch icon17

+ 13 other calls in file

126
127
128
129
130
131
132
133
134
135
const url = new URL(target);

let ip = null

if (target.indexOf(".onion") != -1) {
	ip = url.hostname
} else {
	setInterval(() => {
		dns.lookup(url.hostname, 4, (err, address, family) => {
			ip = address
fork icon1
star icon0
watch icon1