File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
src/WebCompiler/Dependencies Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,14 @@ public override void UpdateFileDependencies(string path)
49
49
string content = File . ReadAllText ( info . FullName ) ;
50
50
51
51
//match both <@import "myFile.scss";> and <@import url("myFile.scss");> syntax
52
- var matches = System . Text . RegularExpressions . Regex . Matches ( content , "@import([\\ s]+)(\\ ([\\ S]+\\ )([\\ s]+))?(url\\ ()?('|\" |)(?<url>[^'\" \\ )]+)('|\" |\\ ))" ) ;
52
+ var matches = System . Text . RegularExpressions . Regex . Matches ( content , "@import([\\ s]+)(\\ ([\\ S]+\\ )([\\ s]+))?(url\\ ()?('|\" |)(?<url>[^'\" \\ ):?: ]+)('|\" |\\ ))" ) ;
53
53
foreach ( System . Text . RegularExpressions . Match match in matches )
54
54
{
55
- FileInfo importedfile = new FileInfo ( Path . Combine ( info . DirectoryName , match . Groups [ "url" ] . Value ) ) ;
55
+ FileInfo importedfile = GetFileInfo ( info , match ) ;
56
+
57
+ if ( importedfile == null )
58
+ continue ;
59
+
56
60
//if the file doesn't end with the correct extension, an import statement without extension is probably used, to re-add the extension (#175)
57
61
if ( string . Compare ( importedfile . Extension , FileExtension , StringComparison . OrdinalIgnoreCase ) != 0 )
58
62
{
@@ -72,5 +76,20 @@ public override void UpdateFileDependencies(string path)
72
76
}
73
77
}
74
78
}
79
+
80
+ private static FileInfo GetFileInfo ( FileInfo info , System . Text . RegularExpressions . Match match )
81
+ {
82
+ string url = match . Groups [ "url" ] . Value ;
83
+
84
+ try
85
+ {
86
+ return new FileInfo ( Path . Combine ( info . DirectoryName , match . Groups [ "url" ] . Value ) ) ;
87
+ }
88
+ catch ( Exception )
89
+ {
90
+ // Not a valid file name
91
+ return null ;
92
+ }
93
+ }
75
94
}
76
95
}
You can’t perform that action at this time.
0 commit comments