Skip to content

support charset in data url #76

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

Merged
merged 1 commit into from
Jun 17, 2015
Merged

support charset in data url #76

merged 1 commit into from
Jun 17, 2015

Conversation

LinusU
Copy link
Collaborator

@LinusU LinusU commented Jun 16, 2015

This is the fix first suggested by @nopnop in #65 but slightly modified for code readability and with added test.

Inline source map prefix should contain an charset:
data:application/json;charset:utf-8;base64,

This is the case with the last releases of browserify for instance.
This fix make inline source map detection more flexible to support
this kind of data url (not only with charset) and use a regexp instead
of a static string: /^data:application/json[^,]+base64,/

(I didn’t push the generated browser-source-map-support.js with this
PR, do you want me to ?)

@LinusU LinusU mentioned this pull request Jun 16, 2015
@nopnop
Copy link

nopnop commented Jun 16, 2015

Thanks @LinusU
@julien-f : #65 closed, this PR looks like a good fix

@LinusU LinusU mentioned this pull request Jun 16, 2015
@LinusU
Copy link
Collaborator Author

LinusU commented Jun 16, 2015

Test passes in browser! Good to merge 👍

} catch (e) {
compareLines(e.stack.split('\n'), expected);
}
fs.unlinkSync('.generated.js');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you create/delete .generated.js yourself instead of using compareStackTrace()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compareStackTrance() is hard coded to use data:application/json;base64, (aka. no charset). I didn't want to change it because we should test for both. I didn't want to add an extra parameter because I felt that it added too much clutter vs. the benefit, thus I just inlined the relevant parts in this test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Would you mind adding a small comment above the test explaining that this is some duplicated code and why it is reasonable to do so?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

julien-f added a commit that referenced this pull request Jun 17, 2015
support charset in data url
@julien-f julien-f merged commit e0842b9 into evanw:master Jun 17, 2015
@LinusU LinusU deleted the patch-1 branch June 17, 2015 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants