Skip to content

Ignore minified JavaScript files #45

@swissspidy

Description

@swissspidy

Right now, we exclude some files by default. One file pattern that we don't yet exclude is minified JavaScript files. They usually look like i-am-minified.min.js.

It's not currently possible to exclude files using glob patterns like *.min.js but I think that would be a great addition.

When someone excludes *.min.js, we can turn this into a regex à la .*\.min.js or something, and then exclude the file if it matches that regex. WP_oEmbed::get_provider() has some code that does this. Perhaps we can reuse this.

In the PHP extractor, the relevant code is here:

/** @var DirectoryIterator $file */
if ( in_array( $file->getBasename(), $exclude, true ) ) {
return false;
}
// Check for more complex paths, e.g. /some/sub/folder.
foreach( $exclude as $path_or_file ) {
if ( false !== mb_ereg( preg_quote( '/' . $path_or_file ) . '$', $file->getPathname() ) ) {
return false;
}
}
/** @var RecursiveCallbackFilterIterator $iterator */
if ( $iterator->hasChildren() ) {
return true;
}
return ( $file->isFile() && 'php' === $file->getExtension() );

We can probably extend this with a new regex.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions