Skip to content

Commit 39bc009

Browse files
committed
Update container.js
Fixed #4863
1 parent f04e576 commit 39bc009

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/container.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function loadGherkinSteps(paths) {
469469
loadSupportObject(path, `Step Definition from ${path}`)
470470
}
471471
} else {
472-
const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : ''
472+
const folderPath = paths.startsWith('.') ? normalizeAndJoin(global.codecept_dir, paths) : ''
473473
if (folderPath !== '') {
474474
globSync(folderPath).forEach(file => {
475475
loadSupportObject(file, `Step Definition from ${file}`)
@@ -562,3 +562,16 @@ function getHelperModuleName(helperName, config) {
562562
// built-in helpers
563563
return `./helper/${helperName}`
564564
}
565+
566+
function normalizeAndJoin(basePath, subPath) {
567+
// Normalize the path (handles extra slashes and resolves `..`)
568+
let normalizedBase = path.normalize(basePath);
569+
let normalizedSub = path.normalize(subPath);
570+
571+
// Replace backslashes with forward slashes
572+
normalizedBase = normalizedBase.replace(/\\/g, '/');
573+
normalizedSub = normalizedSub.replace(/\\/g, '/');
574+
575+
// Join the paths using POSIX-style
576+
return path.posix.join(normalizedBase, normalizedSub);
577+
}

0 commit comments

Comments
 (0)