-
Notifications
You must be signed in to change notification settings - Fork 30
Conversation
1c871c5
to
d63937e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request!
Can you add tests for this? (I'm sorry, the tests are super old and horrible to work with, but it would be nice having tests for this.)
lib/source-map-resolve-node.js
Outdated
.map(function(x) { | ||
return x.slice('charset='.length) | ||
}) | ||
.pop() || defaultCharset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what happens if charset
is provided multiple times? Is it an error? Does the first one win? The last one?
I also think we should do something like this:
var dataUriRegex = /^data:([^,;]*)(?:;([^,;]+))?(?:,(.*))?$/
var mimeType = dataUri[1]
var parameters = (dataUri[2] || "").split(";")
var encoded = dataUri[3] || ""
var charsetRegex = /^charset=(.+)$/
var charset = parameters.reduce(function(result, param) {
var match = charsetRegex.exec(param)
return match ? match[1] : result
}, "us-ascii")
// ...
parameters[parameters.length - 1] === "base64" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first one win in Firefox and chrome.
and more, https://tools.ietf.org/html/rfc8259#section-8.1 only allow use utf-8. maybe we could ignore charset and always use utf-8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always using utf-8 sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check charset and console.warn
or throw new Error
if charset is not utf-8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think that’s necessary. I think we can just assume utf-8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lydell Hi,Do you have time to add a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the reminder! I’m working on it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lydell you can push to my repo now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but I’m too lazy to move back over here now.
close #13
@lydell