Skip to content

URL-matching bug when url doesn't end in a forward slash #1

@eliath

Description

@eliath

The following regex matches URL's pretty damn well, but won't match URLs that DON'T end with a forward slash (/).

/^(http|https)\:\/\/[\w\d\-_]+(\.[\w\d\-_]+)+([\w\-\.,@?^=%&\:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/

This actually might not be the problem, it could be something with the following code as well:

var url_arr = unsafe.match(url_regex); //test if its a url

    if (url_arr) {
        if (url_arr[url_arr.length-1].match(/(.png|.gif|.jpeg|.jpg)/)) {
                          //do some stuff
        }
}

it seems to be the url_arr[url_arr.length-1] that is undefined.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions