Skip to content

Commit 4cd29d8

Browse files
authored
Merge pull request #3089 from mgreter/bugfix/win-abspath-without-dir
Fix abspath handling on windows without directory
2 parents f63b00d + 360efc1 commit 4cd29d8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/file.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ namespace Sass {
234234

235235
sass::string path_for_console(const sass::string& rel_path, const sass::string& abs_path, const sass::string& orig_path)
236236
{
237-
// magic algorith goes here!!
237+
// magic algorithm goes here!!
238238

239239
// if the file is outside this directory show the absolute path
240240
if (rel_path.substr(0, 3) == "../") {
@@ -247,7 +247,15 @@ namespace Sass {
247247
// create an absolute path by resolving relative paths with cwd
248248
sass::string rel2abs(const sass::string& path, const sass::string& base, const sass::string& cwd)
249249
{
250-
return make_canonical_path(join_paths(join_paths(cwd + "/", base + "/"), path));
250+
sass::string rv = make_canonical_path(join_paths(join_paths(cwd + "/", base + "/"), path));
251+
#ifdef _WIN32
252+
// On windows we may get an absolute path without directory
253+
// In that case we should prepend the directory from the root
254+
if (rv[0] == '/' && rv[1] != '/') {
255+
rv.insert(0, cwd, 0, 2);
256+
}
257+
#endif
258+
return rv;
251259
}
252260

253261
// create a path that is relative to the given base directory

0 commit comments

Comments
 (0)