Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly encode Base64 variant params from ix-src. #110

Merged
merged 2 commits into from
Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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