diff --git a/src/Behat/MinkExtension/Context/RawMinkContext.php b/src/Behat/MinkExtension/Context/RawMinkContext.php index e7c1726c..4c997f6c 100644 --- a/src/Behat/MinkExtension/Context/RawMinkContext.php +++ b/src/Behat/MinkExtension/Context/RawMinkContext.php @@ -134,9 +134,22 @@ public function visitPath($path, $sessionName = null) */ public function locatePath($path) { - $startUrl = rtrim($this->getMinkParameter('base_url'), '/') . '/'; - - return 0 !== strpos($path, 'http') ? $startUrl . ltrim($path, '/') : $path; + if (0 === strpos($path, 'http')) { + return $path; + } + + $parts = parse_url($this->getMinkParameter('base_url')); + $path = ltrim($path, '/'); + $parts['path'] = empty($parts['path']) ? '/' : rtrim($parts['path'], '/') . '/'; + + $url = empty($parts['scheme']) ? 'http' : $parts['scheme']; + $url .= '://'; + $url .= empty($parts['user']) ? '' : ($parts['user'] . (empty($parts['pass']) ? '' : ':' . $parts['pass']) . '@'); + $url .= $parts['host'] . $parts['path'] . $path; + $url .= empty($parts['query']) ? '' : '?' . $parts['query']; + $url .= empty($parts['fragment']) ? '' : '#' . $parts['fragment']; + + return $url; } /**