Skip to content

Commit

Permalink
Fixed bug which would remove lines of html code between two comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TwentyFourMinutes committed Mar 24, 2020
1 parent 988196d commit 5ea9b78
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/RazorMinifier/RazorMinifier.Core/Minifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ namespace RazorMinifier.Core
public static class Minifier
{
private static readonly Regex _emptyLineRegex;
private static readonly Regex _simpleCommentRegex;
private static readonly Regex _multiLineCommentRegex;
private static readonly Regex _razorSectionRegex;
private static readonly Regex _razorFunctionsRegex;

static Minifier()
{
_emptyLineRegex = new Regex(@"(^(\s)+|(\s)*(\v|\n|\r))", RegexOptions.Multiline);
_simpleCommentRegex = new Regex(@"(?<!:)\/\/.*");
_multiLineCommentRegex = new Regex(@"(<!--(.|\n)*-->|\/\*(.|\n)*\*\/|@\*(.|\n)*\*@)");
_multiLineCommentRegex = new Regex(@"(<!--(.|\n)*?-->|\/\*(.|\n)*?\*\/|@\*(.|\n)*?\*@)");
_razorSectionRegex = new Regex(@"@section\s\w+\s?{");
_razorFunctionsRegex = new Regex(@"@functions\s\w+\s?{");
}
Expand Down Expand Up @@ -50,8 +48,6 @@ public static string Minify(string input)
}
}

input = _simpleCommentRegex.Replace(input, string.Empty);

input = _multiLineCommentRegex.Replace(input, string.Empty);

input = _emptyLineRegex.Replace(input, string.Empty);
Expand Down

0 comments on commit 5ea9b78

Please sign in to comment.