Skip to content

Commit

Permalink
Merge pull request #110 from imgix/fix-64-params-from-ix-src
Browse files Browse the repository at this point in the history
Properly encode Base64 variant params from ix-src.
  • Loading branch information
paulstraw committed Sep 12, 2016
2 parents e5b72fc + f68fb2a commit 666aa1e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions dist/imgix.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ var ImgixTag = (function() {

if (this.ixPathVal) {
params = JSON.parse(this.ixParamsVal) || {};

// Encode any passed Base64 variant params
for (var key in params) {
if (key.substr(-2) === '64') {
params[key] = util.encode64(params[key]);
}
}
} else {
// If the user used `ix-src`, we have to extract the base params
// from that string URL.
Expand All @@ -65,6 +58,13 @@ var ImgixTag = (function() {
}
}

// Encode any passed Base64 variant params
for (var key in params) {
if (key.substr(-2) === '64') {
params[key] = util.encode64(params[key]);
}
}

if (imgix.config.includeLibraryParam) {
params.ixlib = 'imgixjs-' + imgix.VERSION;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/imgix.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<body>
<div class="wrapper">
<img
ix-src="https://assets.imgix.net/unsplash/hotairballoon.jpg?w=300&amp;h=500&amp;fit=crop&amp;crop=right"
ix-src="https://assets.imgix.net/unsplash/hotairballoon.jpg?w=300&amp;h=500&amp;fit=crop&amp;crop=right&amp;auto64=compress,format"
alt="A lighthouse"
sizes="(min-width: 300px) 300px, calc(100vw - 20px)"
>
Expand Down
2 changes: 1 addition & 1 deletion spec/ImgixTagSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('ImgixTag', function() {
expect(tag._extractBaseParams()).toEqual({
page: '3',
w: '600',
txt64: 'gibberish'
txt64: 'Z2liYmVyaXNo'
});
});

Expand Down
14 changes: 7 additions & 7 deletions src/ImgixTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ var ImgixTag = (function() {

if (this.ixPathVal) {
params = JSON.parse(this.ixParamsVal) || {};

// Encode any passed Base64 variant params
for (var key in params) {
if (key.substr(-2) === '64') {
params[key] = util.encode64(params[key]);
}
}
} else {
// If the user used `ix-src`, we have to extract the base params
// from that string URL.
Expand All @@ -64,6 +57,13 @@ var ImgixTag = (function() {
}
}

// Encode any passed Base64 variant params
for (var key in params) {
if (key.substr(-2) === '64') {
params[key] = util.encode64(params[key]);
}
}

if (imgix.config.includeLibraryParam) {
params.ixlib = 'imgixjs-' + imgix.VERSION;
}
Expand Down

0 comments on commit 666aa1e

Please sign in to comment.