Skip to content

Commit 6d977af

Browse files
committed
Merge pull request #7 from the-grid/dataurl
return data: URL unchanged
2 parents 8a60e45 + ac6bdc9 commit 6d977af

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

lib/imgflo-url.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imgflo-url",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Conveniently produce authorized imgflo URLs.",
55
"main": "lib/imgflo-url.js",
66
"keywords": [

spec/imgflo-url.coffee

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ describe 'imgflo-url', ->
9696
expect(url).to.equal 'https://a.com/b.gif'
9797

9898

99+
context 'with an input data: URL', ->
100+
101+
it 'should return the same URL', ->
102+
config = getConfig()
103+
104+
url = imgflo config, 'passthrough',
105+
input: 'data:image/gif;base64,R0lGODlhDwAMAL...'
106+
107+
expect(url).to.equal 'data:image/gif;base64,R0lGODlhDwAMAL...'
108+
109+
99110
describe 'without a graph name', ->
100111

101112
it 'should throw an error', ->

src/imgflo-url.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ imgflo = (config, graph, params, format) ->
3131
throw new Error 'imgflo params must contain an "input" key' unless input?
3232

3333
parsed = url.parse input
34+
return input if parsed.protocol is 'data:'
35+
3436
match = path.extname(parsed.pathname).match(/^\.(\w+)/)
3537
extension = match?[1].toLowerCase()
3638
return input if extension is 'gif'

0 commit comments

Comments
 (0)