Skip to content

Commit

Permalink
IRT-871 supporting local GDPR script handling (#102)
Browse files Browse the repository at this point in the history
* IRT-871 supporting local GDPR script handling

* IRT-871 update version
  • Loading branch information
jakma authored Dec 9, 2021
1 parent d587eb8 commit e507d26
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/arcads.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arcads",
"version": "6.1.2",
"version": "6.2.0",
"description": "ArcAds is a GPT wrapper created by Arc XP with publishers in mind.",
"main": "dist/arcads.js",
"files": [
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('appendResource', () => {
appendChild: appendChildMock,
},
createElement: jest.fn().mockReturnValue({}),
querySelectorAll: jest.fn().mockReturnValue([]),
};
});

Expand Down Expand Up @@ -49,4 +50,10 @@ describe('appendResource', () => {
expect(appendChildMock).toHaveBeenCalledWith(expectedParams);
expect(cbMock).toHaveBeenCalledTimes(1);
});

it('if script already exists', () => {
global.document.querySelectorAll = jest.fn().mockReturnValue(['Node']);
appendResource('script', 'www.test.com');
expect(appendChildMock).toHaveBeenCalledTimes(0);
});
});
3 changes: 2 additions & 1 deletion src/util/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
**/
export function appendResource(tagname, url, async, defer, cb) {
const tag = document.createElement(tagname);
if (tagname === 'script') {
if (tagname === 'script'
&& typeof document.querySelectorAll(`script[src="${url}"]`)[0] === 'undefined') {
tag.src = url;
tag.async = async || false;
tag.defer = async || defer || false;
Expand Down

0 comments on commit e507d26

Please sign in to comment.