PHP 7.4.33
Preview: calculate-server-name.js Size: 449 B
/usr/share/nodejs/http2-wrapper/source/utils/calculate-server-name.js
'use strict';
const {isIP} = require('net');
const assert = require('assert');

const getHost = host => {
	if (host[0] === '[') {
		const idx = host.indexOf(']');

		assert(idx !== -1);
		return host.slice(1, idx);
	}

	const idx = host.indexOf(':');
	if (idx === -1) {
		return host;
	}

	return host.slice(0, idx);
};

module.exports = host => {
	const servername = getHost(host);

	if (isIP(servername)) {
		return '';
	}

	return servername;
};

Directory Contents

Dirs: 0 × Files: 10
Name Size Perms Modified Actions
449 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
473 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
652 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
1.45 KB lrw-r--r-- 2021-11-20 15:22:42
Edit Download
186 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
237 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
149 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
2.33 KB lrw-r--r-- 2021-11-20 15:22:42
Edit Download
385 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
400 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).