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

Fixing overlapping regex for #31 #32

Merged
merged 1 commit into from
Sep 2, 2017
Merged

Conversation

gbochenek
Copy link
Contributor

Overlapping regex matches were causing define:define and require:require strings to not be replaced correctly. Added a look ahead to fix this issue.

Overlapping regex matches were causing define:define and require:require strings to not be replaced correctly.  Added a look ahead to fix this issue.
@gbochenek
Copy link
Contributor Author

@tomwayson I was hoping to add a unit test here, but Ember builds out the app before testing. Any tips on running a unit test or two on the actual build hooks?

Copy link
Member

@tomwayson tomwayson left a comment

Choose a reason for hiding this comment

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

Thanks @gbochenek!

I will pull and try this shortly.

Re: testing the addon code, I think you just write node tests. I don't know if @odoe did any for the regexes in ember-cli-amd (which I would assume would also be affected by this bug), or if @dmfenton or @mjuniper know of a more emberish way to test the code in index.js.

match: /([^A-Za-z0-9_#]|^|["])define(\W|["]|$)/g,
replacement: '$1efineday$2'
match: /([^A-Za-z0-9_#]|^|["])define(?=\W|["]|$)/g,
replacement: '$1efineday'
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the $2 from the replacements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the lookahead, there is no second grouping, and "$2" will be appended on every match.

@tomwayson
Copy link
Member

@gbochenek nice work!

I have pulled this and verified that it works in the dummy app as well as w/ npm test. I then was able to npm link to my 2.14.2 app and run a production build and verify that it worked.

I assume you able to verify that this fixed the production build issue that you saw in your app, right?

If so, I'll merge and release. The regex tests would be nice to have, but I'd rather get this bug fixed sooner than later. I can open a separate issue to add node tests for index.js.

@gbochenek
Copy link
Contributor Author

@tomwayson

Excellent. I've verified that this fixes the production build issue in my app as well. Lets ship it.

@tomwayson
Copy link
Member

tomwayson commented Sep 2, 2017

Released in v0.1.4

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.

None yet

2 participants