Skip to content

Commit f04e576

Browse files
committed
Update Appium.js
Fixed #4865 Enhancement: Prevent Double Slashes in Appium Endpoint URL Overview: This update improves the _buildAppiumEndpoint() function by ensuring the path does not end with a trailing slash. This prevents potential issues with double slashes when constructing the Appium REST API endpoint URL. Changes: Introduced normalizedPath, which removes a trailing slash from path using .replace(/\/$/, ''). Updated the return statement to use normalizedPath instead of path. Benefits: ✅ Prevents malformed URLs with double slashes. ✅ Improves consistency and reliability of API requests. ✅ Enhances code readability and maintainability.
1 parent 52b6e74 commit f04e576

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/helper/Appium.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,10 @@ class Appium extends Webdriver {
383383

384384
_buildAppiumEndpoint() {
385385
const { protocol, port, hostname, path } = this.browser.options
386+
// Ensure path does NOT end with a slash to prevent double slashes
387+
const normalizedPath = path.replace(/\/$/, '');
386388
// Build path to Appium REST API endpoint
387-
return `${protocol}://${hostname}:${port}${path}/session/${this.browser.sessionId}`
389+
return `${protocol}://${hostname}:${port}${normalizedPath}/session/${this.browser.sessionId}`
388390
}
389391

390392
/**

0 commit comments

Comments
 (0)