Skip to content

file's accepted mimetypes as "*" results in a regex error #2487

Open
@beszabo1

Description

@beszabo1

Sorry if this is the intended behavior, but while updating this package from an old version (1.14 to 1.20) we came across this issue, so I wanted to create a note of it. Maybe it should be more of a feature request, but it is inconsistent given how the default "image/*" is handled.

Current behavior

Providing the accept as "*" resolves it as a faulty regex (since it is)

Expected behavior

Handle "*" as ".*", similar to how "/*" is handled as "/.*", or more realistically do this only when a single "*" is provided.

Live demo

....validate({
                rules: {
                    file_input: {
                        required: true,
                        extension: "gif|json",
                        accept: "*" // currently using ".*" for the code to run as expected
                    }
                },

Relevant code line

https://github.com/jquery-validation/jquery-validation/blob/master/src/additional/accept.js#L22

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