Skip to content

Commit

Permalink
coerces server baseUrl into JS URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisC committed Aug 1, 2024
1 parent 04c94ee commit d9a2019
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/host/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function hostMain(options) {
emitter.on(HostMessage.STOP_RUNNER, () => resolve());
}),
timesOption,
baseUrl: serverDirectory.baseUrl,
baseUrl: new URL(serverDirectory.baseUrl.toString()),
mock: runnerMockOptions({
mock: runnerMock,
mockOpenPage: runnerMockOpenPage,
Expand Down
2 changes: 1 addition & 1 deletion src/runner/create-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { createATDriver } from './at-driver.js';
/**
* @param {object} options
* @param {{hostname: string, port: number | string, pathname: string}} options.atDriverUrl
* @param {AriaATCIShared.BaseURL} options.baseUrl
* @param {URL} options.baseUrl
* @param {AriaATCIHost.Log} options.log
* @param {Promise<void>} options.abortSignal
* @param {AriaATCIRunner.MockOptions} [options.mock]
Expand Down
6 changes: 2 additions & 4 deletions src/runner/driver-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { RunnerMessage } from './messages.js';
export class DriverTestRunner {
/**
* @param {object} options
* @param {AriaATCIShared.BaseURL} options.baseUrl
* @param {URL} options.baseUrl
* @param {AriaATCIHost.Log} options.log
* @param {BrowserDriver} options.browserDriver
* @param {ATDriver} options.atDriver
Expand Down Expand Up @@ -288,10 +288,8 @@ export class DriverTestRunner {
}

_appendBaseUrl(pathname) {
// protocol ends with a ':' and pathname starts with a '/'
const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`;
const newPath = `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${pathname}`;
return new URL(newPath, base);
return new URL(newPath, this.baseUrl.toString());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/runner/mock-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { validateKeysFromCommand } from './driver-test-runner.js';
export class MockTestRunner {
/**
* @param {object} options
* @param {AriaATCIShared.BaseURL} options.baseUrl
* @param {URL} options.baseUrl
* @param {AriaATCIHost.Log} options.log
* @param {AriaATCIRunner.MockOptions} options.mock
*/
Expand Down Expand Up @@ -64,11 +64,10 @@ export class MockTestRunner {
* @param {AriaATCIData.CollectedTest} task
*/
async run(task) {
const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`;
await this.openPage(
new URL(
`${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${task.target.referencePage}`,
base
this.baseUrl.toString()
)
);

Expand Down

0 comments on commit d9a2019

Please sign in to comment.