Skip to content

Commit

Permalink
Merge pull request #441 from am11/issue-242
Browse files Browse the repository at this point in the history
SourceMap: Fix relative paths for Windows (#242)
  • Loading branch information
Aaron Leung committed Jul 28, 2014
2 parents aa02300 + bbc02f3 commit 61edd14
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
18 changes: 17 additions & 1 deletion file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,24 @@ namespace Sass {
return (is_absolute_path(path) ? path : join_paths(cwd, path));
}

string resolve_relative_path(const string& uri, const string& base, const string& cwd)
string resolve_relative_path(const string& uri, const string& base, const string& cwd, const bool recurse)
{
if (!recurse) {
#ifdef _WIN32
// Convert all paths to lower case for Windows
string uri2(uri);
transform(uri.begin(), uri.end(), uri2.begin(), tolower);

string base2(base);
transform(base.begin(), base.end(), base2.begin(), tolower);

string cwd2(cwd);
transform(cwd.begin(), cwd.end(), cwd2.begin(), tolower);

return resolve_relative_path(uri2, base2, cwd2, true);
#endif
}

string absolute_uri = make_absolute_path(uri, cwd);
string absolute_base = make_absolute_path(base, cwd);

Expand Down
2 changes: 1 addition & 1 deletion file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Sass {
string join_paths(string, string);
bool is_absolute_path(const string& path);
string make_absolute_path(const string& path, const string& cwd);
string resolve_relative_path(const string& uri, const string& base, const string& cwd);
string resolve_relative_path(const string& uri, const string& base, const string& cwd, const bool recurse=false);
char* resolve_and_load(string path, string& real_path);
char* read_file(string path);
}
Expand Down
28 changes: 20 additions & 8 deletions sass_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ extern "C" {
source_maps = true;
source_map_file = c_ctx->source_map_file;
}
string output_path = c_ctx->output_path ? c_ctx->output_path : "";
string input_path = c_ctx->input_path ? c_ctx->input_path : "";
int lastindex = input_path.find_last_of(".");
string output_path;
if (!c_ctx->output_path) {
output_path = (lastindex > -1 ? input_path.substr(0, lastindex) : input_path) + ".css";
}
else {
output_path = c_ctx->output_path;
}
Context cpp_ctx(
Context::Data().source_c_str(c_ctx->source_string)
.entry_point(c_ctx->input_path ?
c_ctx->input_path :
"")
.entry_point(input_path)
.output_path(output_path)
.output_style((Output_Style) c_ctx->options.output_style)
.source_comments(c_ctx->options.source_comments == SASS_SOURCE_COMMENTS_DEFAULT)
Expand Down Expand Up @@ -157,11 +163,17 @@ extern "C" {
source_maps = true;
source_map_file = c_ctx->source_map_file;
}
string output_path = c_ctx->output_path ? c_ctx->output_path : "";
string input_path = c_ctx->input_path ? c_ctx->input_path : "";
int lastindex = input_path.find_last_of(".");
string output_path;
if (!c_ctx->output_path) {
output_path = (lastindex > -1 ? input_path.substr(0, lastindex) : input_path) + ".css";
}
else {
output_path = c_ctx->output_path;
}
Context cpp_ctx(
Context::Data().entry_point(c_ctx->input_path ?
c_ctx->input_path :
"")
Context::Data().entry_point(input_path)
.output_path(output_path)
.output_style((Output_Style) c_ctx->options.output_style)
.source_comments(c_ctx->options.source_comments == SASS_SOURCE_COMMENTS_DEFAULT)
Expand Down

0 comments on commit 61edd14

Please sign in to comment.