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

feat!: Support URI encoded source maps #75

Merged
merged 10 commits into from
Oct 15, 2022

Conversation

prantlf
Copy link
Contributor

@prantlf prantlf commented Jan 15, 2022

  • Export a new regex compliant with RFC 2397.
  • Recognise comments without base64 encoding.
  • Add methods to convert from and to uri encoded strings.

Fixes #59 without dropping the compatibility.

index.js Outdated Show resolved Hide resolved
@thlorenz
Copy link
Owner

I like this in general, but we gotta be super careful here. Every time we change the regex it may break in certain scenarios.

If the RFC regex is more correct we should make it the default going forward and just provide the old one for people upgrading that run into issues.
However we have a PR open that reduces the chance of stackoverflows due to recursion when processing the regex (#65) and this RFC regex does not have those non-greedy features.

Did anyone actually complain ever that our existing regex doesn't match correctly?

@phated
Copy link
Collaborator

phated commented Oct 10, 2022

Did anyone actually complain ever that our existing regex doesn't match correctly?

Jdalton complained in #59

@phated
Copy link
Collaborator

phated commented Oct 10, 2022

Since we are going to release this as a major. Can we remove the original commentRegex and combine the 2 new ones into a single? I still don't understand the need for two new RegExps

* Export a new regex compliant with RFC 2397.
* Recognise comments without base64 encoding.
* Add methods to convert from and to uri encoded strings.
@phated phated force-pushed the support-uri-encoding branch from 1a32706 to 73379c5 Compare October 10, 2022 21:08
@phated phated changed the title fix: Support uri encoded source maps feat!: Support URI encoded source maps Oct 10, 2022
@phated
Copy link
Collaborator

phated commented Oct 10, 2022

@thlorenz I've rebased this and combined all the RegExp changes into a single modification of commentRegex that keeps the non-greedy changes from #65 - want to take a look?

Please note that this also removed the : separator for charsets because that isn't valid as per https://datatracker.ietf.org/doc/html/rfc2397 (but this was already going to be a breaking change). It cleaned up some of the test code.

@phated phated requested a review from thlorenz October 10, 2022 22:03
@phated
Copy link
Collaborator

phated commented Oct 10, 2022

Here is a visualization of the new regexp
regexp

Copy link
Owner

@thlorenz thlorenz left a comment

Choose a reason for hiding this comment

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

Thanks for all the work putting this together.
Let's clean up the questions/requests I had and I'll have another look.

From what I can tell the regex looks fine, but just want to make sure the original behavior didn't change and we need the tests to be as unmodified as possible to be sure of that.

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
test/comment-regex.js Outdated Show resolved Hide resolved
t.ok(comment(x, ''), 'matches ' + x)
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset')
t.ok(comment(x, '', convert.commentRegex), 'matches ' + x)
Copy link
Owner

Choose a reason for hiding this comment

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

ditto here .. existing tests should be touched as little as possible to ensure nothing breaks

test/comment-regex.js Outdated Show resolved Hide resolved
test/comment-regex.js Show resolved Hide resolved
test/convert-source-map.js Outdated Show resolved Hide resolved
@phated
Copy link
Collaborator

phated commented Oct 14, 2022

This introduces a subtle (but necessary) breaking change with the regexp. It will no longer parse a sourcemap that had the encoding specified at charset:utf-8; however, it doesn't seem that was ever (??) valid syntax for a data-uri, so I don't know if it will actually affect any users.

@phated phated requested a review from thlorenz October 14, 2022 22:55
Copy link
Owner

@thlorenz thlorenz left a comment

Choose a reason for hiding this comment

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

LGTM thanks for your patience and making this perfect :)

Feel free to squash and merge + LMK your npm user and I'll add you so you can publish.

As discussed this needs to be a major bump since it breaks backwards compat.

@phated phated merged commit e6b18c4 into thlorenz:master Oct 15, 2022
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.

sourceMappingURL with non-base64 data URI not supported.
3 participants