Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ function loadGherkinSteps(paths) {
loadSupportObject(path, `Step Definition from ${path}`)
}
} else {
const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : ''
const folderPath = paths.startsWith('.') ? normalizeAndJoin(global.codecept_dir, paths) : ''
if (folderPath !== '') {
globSync(folderPath).forEach(file => {
loadSupportObject(file, `Step Definition from ${file}`)
Expand Down Expand Up @@ -562,3 +562,16 @@ function getHelperModuleName(helperName, config) {
// built-in helpers
return `./helper/${helperName}`
}

function normalizeAndJoin(basePath, subPath) {
// Normalize the path (handles extra slashes and resolves `..`)
let normalizedBase = path.normalize(basePath);
let normalizedSub = path.normalize(subPath);

// Replace backslashes with forward slashes
normalizedBase = normalizedBase.replace(/\\/g, '/');
normalizedSub = normalizedSub.replace(/\\/g, '/');

// Join the paths using POSIX-style
return path.posix.join(normalizedBase, normalizedSub);
}
4 changes: 3 additions & 1 deletion lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,10 @@ class Appium extends Webdriver {

_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(/\/$/, '');
// Build path to Appium REST API endpoint
return `${protocol}://${hostname}:${port}${path}/session/${this.browser.sessionId}`
return `${protocol}://${hostname}:${port}${normalizedPath}/session/${this.browser.sessionId}`
}

/**
Expand Down
Loading