Skip to content

Commit

Permalink
fix(url): hashes are removed from test pages #79
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Mar 16, 2024
1 parent 6a73b9f commit 12dc829
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/add-test-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
const { stop } = require('./browsers')
const { URL } = require('url')
const { getOutput } = require('./output')
const { stripUrlHash } = require('./tools')

module.exports = {
async addTestPages (job, url, pages) {
getOutput(job).debug('probe', `addTestPages from ${url}`, pages)
let testPageUrls
pages = pages.map(relativeUrl => {
const absoluteUrl = new URL(relativeUrl, url)
return absoluteUrl.toString()
return stripUrlHash(absoluteUrl.toString())
})
if (job.pageFilter) {
const filter = new RegExp(job.pageFilter)
Expand Down
9 changes: 9 additions & 0 deletions src/add-test-pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,14 @@ describe('src/add-test-pages', () => {
'http://localhost:8045/page2.html'
])
})

it('strips hash from the URLs', async () => {
await addTestPages(job, url, ['/page1.html#'])
await addTestPages(job, url, ['http://localhost:8045/page2.html?parameter#hash'])
expect(job.testPageUrls).toEqual([
'http://localhost:8045/page1.html',
'http://localhost:8045/page2.html?parameter'
])
})
})
})

0 comments on commit 12dc829

Please sign in to comment.