Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/views/ad-unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ const NO_AD_SEGMENTS = new Set([
'revisions',
]);

/** Public, indexable pages only. A noindex page is a dashboard or a one-off flow. */
/**
* Public, indexable pages only. A noindex page is a dashboard or a one-off flow,
* and the homepage carries no ad.
*/
export function showsAd(path: string, noindex?: boolean): boolean {
if (noindex) return false;
const first = path.split(/[/?#]/)[1] ?? '';
if (first === '') return false;
return !NO_AD_SEGMENTS.has(first);
}

Expand Down
11 changes: 6 additions & 5 deletions test/views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ test('the ad unit is a crawlproof frame on public pages only, and the policy fra
const { showsAd, AD_SLOT } = await import('../dist/views/ad-unit.js');
const { Layout } = await import('../dist/views/layout.js');
const { securityHeaders } = await import('../dist/server/middleware.js');
assert.equal(showsAd('/', false), true);
assert.equal(showsAd('/', false), false, 'the homepage carries no ad');
assert.equal(showsAd('/jobs/abc', false), true);
assert.equal(showsAd('/me/settings', false), false);
assert.equal(showsAd('/post-a-job', false), false);
Expand All @@ -579,10 +579,11 @@ test('the ad unit is a crawlproof frame on public pages only, and the policy fra
children: 'x',
}),
);
const home = page('/');
assert.equal(home.match(/crawlproof\.com\/api\/ads\/frame/g)?.length, 1, 'exactly one unit');
assert.ok(home.includes(`slot=${AD_SLOT}&format=text_link`), home);
assert.ok(!home.includes('theme='), 'the frame answers prefers-color-scheme itself');
assert.ok(!page('/').includes('/api/ads/frame'), 'no ad on the homepage');
const job = page('/jobs/abc');
assert.equal(job.match(/crawlproof\.com\/api\/ads\/frame/g)?.length, 1, 'exactly one unit');
assert.ok(job.includes(`slot=${AD_SLOT}&format=text_link`), job);
assert.ok(!job.includes('theme='), 'the frame answers prefers-color-scheme itself');
assert.ok(!page('/inbox').includes('/api/ads/frame'), 'no ad inside the inbox');

const headers = new Headers();
Expand Down
2 changes: 1 addition & 1 deletion web/public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ a.badge-plain:hover .badge {

/* CrawlProof ad unit (src/views/ad-unit.tsx): one fluid text_link frame at the top of the content. */
.ad-unit {
margin: 0 0 1.5rem;
margin: 0 0 0.75rem;
}
.ad-unit iframe {
display: block;
Expand Down
2 changes: 1 addition & 1 deletion web/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* drifted, which is the only version of this rule that survives contact.
*/

const VERSION = 'b264b667';
const VERSION = '3a3325d0';
const SHELL = `shell-${VERSION}`;
const ASSETS = ['/assets/app.css', '/assets/tokens.css', '/assets/icon.svg'];

Expand Down
Loading