Closed
Description
The _buildAppiumEndpoint()
function constructs the Appium REST API endpoint URL using path
from this.browser.options
. However, if path
ends with a trailing slash (/
), it results in a double slash (//
) in the final URL before "session".
Steps to Reproduce:
Set path
as '/
' in this.browser.options
:
this.browser.options = {
protocol: 'http',
hostname: '127.0.0.1',
port: 4723,
path: '/' // Root path with a trailing slash
};
this.browser.sessionId = '123456';
Call _buildAppiumEndpoint()
.
The generated URL will be:
http://127.0.0.1:4723//session/123456
Issue: The double slash (//session/) cause API request failures with 404 error.
Resolution:
Modify _buildAppiumEndpoint()
to remove any trailing slash from path
before constructing the URL.
Fix:
_buildAppiumEndpoint() {
const { protocol, port, hostname, path } = this.browser.options;
// Ensure path does NOT end with a slash to prevent double slashes
const normalizedPath = path.replace(/\/$/, '') || '';
return `${protocol}://${hostname}:${port}${normalizedPath}/session/${this.browser.sessionId}`;
}
Fixed Output (Corrected URL):
http://127.0.0.1:4723/session/123456
**
✅ Now, the API request will work as expected without double slashes. 🚀
Metadata
Metadata
Assignees
Labels
No labels