Skip to content

Commit addeec2

Browse files
author
Aaron Leung
committed
Also allowing files to be imported without an extension. I.e., users can say "@import 'foo'" when the file is named "foo.scss".
1 parent 2c8c2ab commit addeec2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

document.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,20 @@ namespace Sass {
3232
const char* path_str = path.c_str();
3333
f = std::fopen(path_str, "rb");
3434
if (!f) {
35-
const char* file_name_str = Prelexer::folders(path_str);
36-
f = std::fopen((Token::make(path_str, file_name_str).to_string() +
37-
"_" +
38-
Token::make(file_name_str).to_string()).c_str(), "rb");
39-
if (!f) throw path;
35+
string path_with_extension(path + ".scss");
36+
f = std::fopen(path_with_extension.c_str(), "rb");
37+
if (!f) {
38+
const char* file_name_str = Prelexer::folders(path_str);
39+
string path_with_underscore(Token::make(path_str, file_name_str).to_string() +
40+
"_" +
41+
Token::make(file_name_str).to_string());
42+
f = std::fopen(path_with_underscore.c_str(), "rb");
43+
if (!f) {
44+
string path_with_underscore_and_extension(path_with_underscore + ".scss");
45+
f = std::fopen(path_with_underscore_and_extension.c_str(), "rb");
46+
if (!f) throw path;
47+
}
48+
}
4049
}
4150
if (std::fseek(f, 0, SEEK_END)) throw path;
4251
int status = std::ftell(f);

0 commit comments

Comments
 (0)