Skip to content

Filter out HTML and JSON #1

@jorendorff

Description

@jorendorff

For some reason, scrapper gathers a lot of stuff that is not JS.

If JSON.parse(sourceText) succeeds then we definitely don't care about it.

HTML is harder to pin down; it's wrong to search for tags, because many JS files contain globs of HTML, for use with .innerHTML.

One solid indicator of HTML is <!doctype or <html at the start of the file.

You can detect whether a string matches Script by doing new Function("", sourceText) and catching the SyntaxError. But it throws for modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions