Skip to content

Regex issue with javascript line comments #47

@qoreycube

Description

@qoreycube

Line 161 in StreamReaderExtension.cs:
htmlContents = Regex.Replace(htmlContents, @"// (.*?)\r?\n", "", RegexOptions.Singleline);

This catches regex expressions in javascripts that have escaped forward slashes. For example:
url += $('#field').val().replace(///g, '').replace(/&/g, 'and').substring(0, 50) + '/';

the regex expression "///g" is valid, but not a comment.

Trying to think of a workaround for this line, but my regex is a little rusty.

I was thinking this:
htmlContents = Regex.Replace(htmlContents, @"[^\\]// (.*?)\r?\n", "", RegexOptions.Singleline);

But that also fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions