Skip to content

Commit

Permalink
Merge pull request #3089 from mgreter/bugfix/win-abspath-without-dir
Browse files Browse the repository at this point in the history
Fix abspath handling on windows without directory
  • Loading branch information
mgreter authored May 1, 2020
2 parents f63b00d + 360efc1 commit 4cd29d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace Sass {

sass::string path_for_console(const sass::string& rel_path, const sass::string& abs_path, const sass::string& orig_path)
{
// magic algorith goes here!!
// magic algorithm goes here!!

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

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

0 comments on commit 4cd29d8

Please sign in to comment.