Skip to content

Commit 1aaaceb

Browse files
Fix scroll position test by correctly extracting hash from href
The href attributes in REX links contain the full path (e.g., "test-page-for-generic-styles#main-content") not just the hash (e.g., "#main-content"). This was causing the selector to be constructed incorrectly as "#test-page-for-generic-styles#main-content" which is an invalid compound ID selector. Changed the targetId extraction from: href?.replace(/^#/, '') to: href?.match(/#(.+)$/)?[1] This properly extracts only the part after the # symbol, resulting in correct selectors like "#main-content". Addresses Review #43 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ffab1cf commit 1aaaceb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/app/content/components/Content.browserspec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ describe('Content', () => {
153153
for (const link of links) {
154154
// Get the href before clicking to know what element we're scrolling to
155155
const href = await page.evaluate((el) => el.getAttribute('href'), link);
156-
const targetId = href?.replace(/^#/, '') || '';
156+
// Extract just the hash part (after the # symbol) from href
157+
// href might be "#main-content" or "page-slug#main-content"
158+
const hashMatch = href?.match(/#(.+)$/);
159+
const targetId = hashMatch ? hashMatch[1] : '';
157160

158161
/* eslint-disable no-console */
159162
console.info('*** Clicking link with href:', href, 'targetId:', targetId);

0 commit comments

Comments
 (0)