Skip to content

Commit e93e4a6

Browse files
committed
fix: exclude CodePen profile pages from playground links (#2110)
1 parent 7f2fc1a commit e93e4a6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/utils/readme.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ interface PlaygroundProvider {
1919
id: string // Provider identifier
2020
name: string
2121
domains: string[] // Associated domains
22-
paths?: string[]
22+
paths?: string[] // pathname must start with one of these
23+
pathContains?: string[] // pathname must contain one of these
2324
icon?: string // Provider icon name
2425
}
2526

@@ -44,6 +45,8 @@ const PLAYGROUND_PROVIDERS: PlaygroundProvider[] = [
4445
name: 'CodePen',
4546
domains: ['codepen.io'],
4647
icon: 'codepen',
48+
// Only match actual pen URLs like /username/pen/id (not profile/collection pages)
49+
pathContains: ['/pen/', '/full/', '/details/'],
4750
},
4851
{
4952
id: 'jsfiddle',
@@ -128,7 +131,8 @@ function matchPlaygroundProvider(url: string): PlaygroundProvider | null {
128131
for (const domain of provider.domains) {
129132
if (
130133
(hostname === domain || hostname.endsWith(`.${domain}`)) &&
131-
(!provider.paths || provider.paths.some(path => parsed.pathname.startsWith(path)))
134+
(!provider.paths || provider.paths.some(path => parsed.pathname.startsWith(path))) &&
135+
(!provider.pathContains || provider.pathContains.some(seg => parsed.pathname.includes(seg)))
132136
) {
133137
return provider
134138
}

0 commit comments

Comments
 (0)