Skip to content

Commit

Permalink
Support Kibana URL parts with stripped default port (#197418)
Browse files Browse the repository at this point in the history
## Summary

This PR adds support for getting Kibana URL parts with stripped default
port.

### Details

* Adds method `getUrlPartsWithStrippedDefaultPort` to `kbnTestConfig`
* Can be used when asserting URLs where the browser strips the default
port
  • Loading branch information
pheyos authored Oct 23, 2024
1 parent 5adb0ea commit 629edc0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/kbn-test/kbn_test_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,21 @@ export const kbnTestConfig = new (class KbnTestConfig {
password,
};
}

/**
* Use to get `port:undefined` for assertions if the port is default for the
* used protocol and thus would be stripped by the browser
*/
getUrlPartsWithStrippedDefaultPort(user: UserAuth = kibanaTestUser): UrlParts {
const urlParts = this.getUrlParts(user);

if (
(urlParts.protocol === 'http' && urlParts.port === 80) ||
(urlParts.protocol === 'https' && urlParts.port === 443)
) {
urlParts.port = undefined;
}

return urlParts;
}
})();

0 comments on commit 629edc0

Please sign in to comment.