@destinationstransfers/google-localized-domain
Advanced tools
Comparing version 1.0.0 to 2.0.2
37
index.js
'use strict'; | ||
const { readFileSync } = require('fs'); | ||
const path = require('path'); | ||
const worldCountries = require('world-countries'); | ||
const { readFileSync } = require('fs'); | ||
/** | ||
* @type {string[]} | ||
* @type {Map.<string, string>} | ||
*/ | ||
const GOOGLE_DOMAINS = readFileSync( | ||
const countryCodeToGoogleDomainMap = readFileSync( | ||
path.resolve(__dirname, './data/googleDomains.txt'), | ||
'utf8' | ||
).split('\n'); | ||
'utf8', | ||
) | ||
.split('\n') | ||
.reduce((map, domain) => { | ||
const country = worldCountries.find(({ tld }) => | ||
tld.some(t => domain.endsWith(t)), | ||
); | ||
if (country) { | ||
map.set(country.cca2, domain); | ||
} | ||
return map; | ||
}, new Map()); | ||
const countryCodeToGoogleDomainMap = new Map(); | ||
GOOGLE_DOMAINS.forEach(domain => { | ||
const country = worldCountries.find(({ tld }) => | ||
tld.some(t => domain.endsWith(t)) | ||
); | ||
if (country) { | ||
countryCodeToGoogleDomainMap.set(country.cca2, domain); | ||
} | ||
}); | ||
// create country code to top level domain map | ||
/** | ||
* Returng Google localized domain for a given country (if exists) or '.google.com' | ||
* | ||
* Returns Google localized domain for a given country (if exists) or '.google.com' | ||
* | ||
* @param {string} countryCode - ISO 3166-1 alpha-2 country code like 'GB' | ||
@@ -42,2 +41,2 @@ * @returns {string} - Google domain with leading dot, like '.google.ae' | ||
} | ||
exports.getByCountryCode = getByCountryCode; | ||
module.exports.getByCountryCode = getByCountryCode; |
{ | ||
"name": "@destinationstransfers/google-localized-domain", | ||
"version": "1.0.0", | ||
"version": "2.0.2", | ||
"description": "Returns Google localized domain (like google.co.uk) querying by country code (like 'GB') or language code (like 'en-GB')", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest" | ||
"test": "node --expose-gc node_modules/jest/bin/jest --detectOpenHandles --detectLeaks --notify --logHeapUsage", | ||
"postinstall": "node util/fetchGoogleDomains" | ||
}, | ||
@@ -33,21 +34,10 @@ "repository": { | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=10" | ||
}, | ||
"devDependencies": { | ||
"@destinationstransfers/eslint-config": "^1.0.2", | ||
"@destinationstransfers/fetch": "^2.1.0", | ||
"eslint": "^4.9.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-node": "^5.2.0", | ||
"jest": "^21.2.1", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-lint-consistent": "^2.0.1", | ||
"remark-preset-lint-recommended": "^3.0.1" | ||
"@destinationstransfers/eslint-config": "6.3.0", | ||
"eslint": "5.14.1", | ||
"jest": "24.1.0", | ||
"weak": "1.0.1" | ||
}, | ||
"remarkConfig": { | ||
"presets": [ | ||
"lint-recommended", | ||
"lint-consistent" | ||
] | ||
}, | ||
"jest": { | ||
@@ -57,11 +47,13 @@ "collectCoverage": true, | ||
"verbose": true, | ||
"bail": true | ||
"bail": true, | ||
"coverageReporters": [ | ||
"text", | ||
"json", | ||
"html", | ||
"cobertura" | ||
] | ||
}, | ||
"eslintConfig": { | ||
"plugins": [ | ||
"node" | ||
], | ||
"extends": [ | ||
"@destinationstransfers", | ||
"plugin:node/recommended" | ||
"@destinationstransfers" | ||
], | ||
@@ -73,17 +65,7 @@ "env": { | ||
"sourceType": "script" | ||
}, | ||
"rules": { | ||
"prefer-object-spread/prefer-object-spread": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"world-countries": "^1.8.1" | ||
"world-countries": "2.1.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
37
6643
1
+ Addedworld-countries@2.1.0(transitive)
- Removedworld-countries@1.8.1(transitive)
Updatedworld-countries@2.1.0