check the domains by removing the subdomain
This commit is contained in:
@@ -12,7 +12,7 @@ import { IS_FIREFOX, generateProjectFromDevSites } from '../utils';
|
|||||||
import { getApiKey } from '../utils/apiKey';
|
import { getApiKey } from '../utils/apiKey';
|
||||||
import changeExtensionState from '../utils/changeExtensionState';
|
import changeExtensionState from '../utils/changeExtensionState';
|
||||||
import contains from '../utils/contains';
|
import contains from '../utils/contains';
|
||||||
import getDomainFromUrl, { getDomainFromUrlWithoutProtocol } from '../utils/getDomainFromUrl';
|
import getDomainFromUrl, { getDomain } from '../utils/getDomainFromUrl';
|
||||||
|
|
||||||
class WakaTimeCore {
|
class WakaTimeCore {
|
||||||
tabsWithDevtoolsOpen: Tabs.Tab[];
|
tabsWithDevtoolsOpen: Tabs.Tab[];
|
||||||
@@ -156,7 +156,7 @@ class WakaTimeCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hostname = getDomainFromUrlWithoutProtocol(url).replace('www.', '');
|
const hostname = getDomain(url);
|
||||||
if (!items.trackSocialMedia) {
|
if (!items.trackSocialMedia) {
|
||||||
if ((items.socialMediaSites as string[]).includes(hostname)) {
|
if ((items.socialMediaSites as string[]).includes(hostname)) {
|
||||||
return changeExtensionState('blacklisted');
|
return changeExtensionState('blacklisted');
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ export default function getDomainFromUrl(url: string): string {
|
|||||||
/**
|
/**
|
||||||
* Returns domain from given URL.
|
* Returns domain from given URL.
|
||||||
*/
|
*/
|
||||||
export function getDomainFromUrlWithoutProtocol(url: string): string {
|
export function getDomain(url: string): string {
|
||||||
const parts = url.split('/');
|
const splittedUrl = url.replace(/(https?:\/\/)?(www.)?/i, '').split('.');
|
||||||
|
const domain = splittedUrl.slice(splittedUrl.length - 2).join('.');
|
||||||
|
if (domain.includes('/')) {
|
||||||
|
return domain.split('/')[0];
|
||||||
|
}
|
||||||
|
|
||||||
return parts[2];
|
return domain;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user