Skip to content

Commit

Permalink
Update isGptImplTag regex to reflect real world url changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jburger424 committed May 8, 2023
1 parent 4b00d37 commit 9c22e8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,25 @@ describe('resource-classification.js', () => {
describe('#isGptImplTag', () => {
const testCases = [
{
description: 'Standard tag matches',
description: 'Legacy tag matches',
url: new URL('https://securepubads.g.doubleclick.net/gpt/pubads_impl_19700101.js?1234'),
expectation: true,
},
{
description: 'Standard tag matches on pagead2',
description: 'Legacy tag matches on pagead2',
url: new URL('https://pagead2.googlesyndication.com/gpt/pubads_impl_19700101.js?1234'),
expectation: true,
},
{
description: 'Standard tag matches',
url: new URL('https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m123/pubads_impl.js'),
expectation: true,
},
{
description: 'Suffixed tag matches',
url: new URL('https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m123/pubads_impl_t123.js'),
expectation: true,
},
{
description: 'Non-standard tag matches',
url: new URL('https://securepubads.g.doubleclick.net/gpt/pubads_impl_modern_19700101.js'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ function isAMPTag(url) {
*/
function isGptImplTag(url) {
return isGoogleAds(url) &&
/(^\/gpt\/pubads_impl([a-z_]*)((?<!rendering)_)\d+\.js)/
.test(toURL(url).pathname);
new RegExp('(^(\\/pagead\\/managed\/js)?\\/gpt\/(m\\d+\\/)?pubads_impl' +
'([a-z_]*)(?<!rendering_)\\d*\\.js)').test(toURL(url).pathname);
}

/**
Expand Down

0 comments on commit 9c22e8b

Please sign in to comment.