Skip to content

Url is encoded twice if already encoded #25

Open

Description

@petertflem

It seems whenever the plugin gets an url that is already encoded, it encodes it again, thus destroying the url.

Perhaps you can test if it is encoded before encoding it, e.g. with a regex, something like /%[0-9A-Z]{2}/g. (that regex needs testing).

Maybe you can do like this:

if (!new RegExp(/%[0-9A-Z]{2}/g).test($img.attr('src'))) {
    // Change
    $imgBoxCont.css({ 'background-image': 'url("' + encodeURI($img.attr('src')) + '")' });
} else {
    // Change
    $imgBoxCont.css({ 'background-image': 'url("' + $img.attr('src') + '")' });
}

Activity

  1. funwhilelost commented on Dec 2, 2014

    @funwhilelost

    Seeing the same thing here. I actually don't think we should need to encode the background-image URL at all.

  2. funwhilelost commented on Dec 2, 2014

    @funwhilelost

    @petertflem I'm working around it by running this snippet just before running imgLiquid:

    if (new RegExp(/%[0-9A-Z]{2}/g).test($img.attr('src'))) {
      $img.attr("src", decodeURIComponent($img.attr("src")));
    }
    $img.parent().imgLiquid({ ... });
    

    YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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