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

fresh regex every time extractCritical is called #177

Merged
merged 3 commits into from
Jul 27, 2017

Conversation

threepointone
Copy link
Contributor

What: Use a fresh regex every time extractCritical is called

Why: regexes are stateful, and the current method would break critical css extraction unexpectedly because of previous runs

How: the regex declaration was brought inside the function

Checklist:

  • Documentation
  • Tests
  • Code complete

@codecov-io
Copy link

codecov-io commented Jul 25, 2017

Codecov Report

Merging #177 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #177      +/-   ##
==========================================
+ Coverage   89.11%   89.13%   +0.02%     
==========================================
  Files          22       22              
  Lines         845      847       +2     
  Branches      219      219              
==========================================
+ Hits          753      755       +2     
  Misses         70       70              
  Partials       22       22
Impacted Files Coverage Δ
src/server.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cceeba4...9a2be66. Read the comment docs.

src/server.js Outdated
@@ -16,6 +14,8 @@ export {
export function extractCritical (html) {
// parse out ids from html
// reconstruct css/rules/cache to pass
const RGX = /css(?:[a-zA-Z0-9-]*)-([a-zA-Z0-9]+)/gm

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to do RGX.lastIndex = 0 after the while loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nyah, it gets GCed and lost anyway after it's done

Copy link
Member

Choose a reason for hiding this comment

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

@tkh44 tkh44 merged commit ec2ac67 into master Jul 27, 2017
@tkh44 tkh44 deleted the extractCritical-regex-fix branch July 27, 2017 04:58
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.

4 participants