Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer committed Jul 19, 2021
1 parent 6e2c693 commit 1ae5174
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,23 @@ const flushQueue = (): void => {
window.__fathomClientQueue = [];
};


/**
* Loops through list of domains and warns if they start with
* http, https, http://, etc... as this does not work with the
* Fathom script.
*
*
* @param domains - List of domains to check
*/
const checkDomainsAndWarn = (domains: string[]): void => {
const regex = /(https?)(?=:|\/|$)/; // matches http or https followed by
// either a : or /
domains.forEach((domain) => {
// either a : or /
domains.forEach(domain => {
if (regex.exec(domain) !== null)
console.warn(`The include domain ${domain} might fail to work as intended as it begins with a transfer protocol (http://, https://), consider removing the protocol portion of the string.`);
console.warn(
`The include domain ${domain} might fail to work as intended as it begins with a transfer protocol (http://, https://). Consider removing the protocol portion of the string.`
);
});
}
};

export const load = (siteId: string, opts?: LoadOptions): void => {
let tracker = document.createElement('script');
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('load', () => {
});

expect(window.console.warn).toHaveBeenCalledWith(
'The include domain https://bobheadxi.dev might fail to work as intended as it begins with a transfer protocol (http://, https://), consider removing the protocol portion of the string.'
'The include domain https://bobheadxi.dev might fail to work as intended as it begins with a transfer protocol (http://, https://). Consider removing the protocol portion of the string.'
);
});
});
Expand Down

0 comments on commit 1ae5174

Please sign in to comment.