Handle hosts with double-tld better in shorthost method

This commit is contained in:
Kuba Orlik 2021-11-24 22:03:03 +01:00
parent 361546bcd4
commit 922d5da074
3 changed files with 16 additions and 4 deletions

11
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@iabtcf/core": "^1.3.1", "@iabtcf/core": "^1.3.1",
"@types/proposal-relative-indexing-method": "^0.1.0",
"esbuild": "^0.13.3", "esbuild": "^0.13.3",
"events": "^3.3.0", "events": "^3.3.0",
"react": "^17.0.2", "react": "^17.0.2",
@ -39,6 +40,11 @@
"integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
"dev": true "dev": true
}, },
"node_modules/@types/proposal-relative-indexing-method": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@types/proposal-relative-indexing-method/-/proposal-relative-indexing-method-0.1.0.tgz",
"integrity": "sha512-qZHcVIMT0+apQmIPSPG50ksZujLkBE1rYQXVBswF9CcwCGij1zIJemXNdfarqQo5wAhA1K+Y0/h0n5bV8dK7sQ=="
},
"node_modules/@types/react": { "node_modules/@types/react": {
"version": "17.0.26", "version": "17.0.26",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz",
@ -386,6 +392,11 @@
"integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
"dev": true "dev": true
}, },
"@types/proposal-relative-indexing-method": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@types/proposal-relative-indexing-method/-/proposal-relative-indexing-method-0.1.0.tgz",
"integrity": "sha512-qZHcVIMT0+apQmIPSPG50ksZujLkBE1rYQXVBswF9CcwCGij1zIJemXNdfarqQo5wAhA1K+Y0/h0n5bV8dK7sQ=="
},
"@types/react": { "@types/react": {
"version": "17.0.26", "version": "17.0.26",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz",

View File

@ -16,6 +16,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@iabtcf/core": "^1.3.1", "@iabtcf/core": "^1.3.1",
"@types/proposal-relative-indexing-method": "^0.1.0",
"esbuild": "^0.13.3", "esbuild": "^0.13.3",
"events": "^3.3.0", "events": "^3.3.0",
"react": "^17.0.2", "react": "^17.0.2",

View File

@ -32,12 +32,12 @@ export type Request = {
}; };
export function getshorthost(host: string) { export function getshorthost(host: string) {
return host const parts = host
.replace(/^.*:\/\//, "") .replace(/^.*:\/\//, "")
.replace(/\/.*$/, "") .replace(/\/.*$/, "")
.split(".") .split(".");
.slice(-2)
.join("."); return parts.slice(parts.at(-2).length > 3 ? -2 : -3).join(".");
} }
export function useEmitter( export function useEmitter(