Skip to content

Commit

Permalink
Merge pull request #2 from parro-it/master
Browse files Browse the repository at this point in the history
added datauri case and test
  • Loading branch information
jprichardson committed Aug 27, 2015
2 parents 09b3de8 + 97923f7 commit 4afc66b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/__tests__/args.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,16 @@ describe('args', function () {
assert.strictEqual(url, 'file:///tmp/index.html')
})
})

describe('> when data uri', function () {
it('should create a url with encoded args in hash', function () {
var uri = 'data:text/plain;charset=utf-8;base64,dGhpcyBpcyBhIHRlc3QK'
var url = args.urlWithArgs(uri, {doThat: 'ok'})
assert.strictEqual(url, uri + '#%7B%22doThat%22%3A%22ok%22%7D')

url = args.urlWithArgs(uri)
assert.strictEqual(url, uri)
})
})
})
})
2 changes: 1 addition & 1 deletion lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function urlWithArgs (urlOrFile, args) {
args = encode(args)

var u
if (urlOrFile.indexOf('http') === 0) {
if (urlOrFile.indexOf('http') === 0 || urlOrFile.indexOf('data') === 0) {
var urlData = url.parse(urlOrFile)
var hash = urlData.hash || args ? args : undefined
u = url.format(assign(urlData, { hash: hash }))
Expand Down

0 comments on commit 4afc66b

Please sign in to comment.