Skip to content

Commit 456df27

Browse files
cursoragentbetegon
andcommitted
fix(platforms): match middle components in platform suggestions (Sentry CLI-WD)
When a user types an invalid platform like 'javascript-cloudflare', the suggestion system failed to suggest 'node-cloudflare-workers' and 'node-cloudflare-pages' because 'cloudflare' appears as a middle component (between dashes), not as a prefix or suffix. Added middle-component matching in findSwapMatches() so that the suffix after the first dash is also checked as a substring between dashes in valid platform names. Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
1 parent 4c837ac commit 456df27

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lib/platforms.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,15 @@ function findSwapMatches(invalid: string): string[] {
208208
const suffixPrefix = `${suffix}-`;
209209
// Try suffix as a component in other platforms (e.g. "*-hono" for suffix "hono")
210210
const suffixSuffix = `-${suffix}`;
211+
// Also match suffix as a middle component (e.g. "cloudflare" in "node-cloudflare-workers")
212+
const suffixMiddle = `-${suffix}-`;
211213
for (const p of VALID_PLATFORMS) {
212214
if (p.startsWith(suffixPrefix) && p !== swapped) {
213215
results.push(p);
214216
} else if (p.endsWith(suffixSuffix) && p !== invalid) {
215217
results.push(p);
218+
} else if (p.includes(suffixMiddle)) {
219+
results.push(p);
216220
}
217221
}
218222

0 commit comments

Comments
 (0)