Created
April 5, 2020 14:09
-
-
Save omrilotan/f2b8b0e5633529858cee492b1eee199d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const providers = [ | |
['googletagmanager.com', 'googletagmanager'], | |
['linkedin.com', 'linkedin'], | |
['d2c7xlmseob604.cloudfront.net', 'smartling'], | |
['d2fltix0v2e0sb.cloudfront.net', 'dev.to'], | |
]; | |
/** | |
* Get the name of the script provider where applicable | |
* @param {string} url | |
* @return {string|undefined} | |
*/ | |
function thirdPartyProvider(url) { | |
const { hostname } = new URL(url); | |
return ( | |
providers.find( | |
([domain]) => hostname.endsWith(domain) | |
) || [] | |
)[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment