galacemiguel / fluid-system

Fluid System is a style props function transformer for generating fluid styles. 💦
MIT License
145 stars 3 forks source link

fix getUnit error on non-single property values #5

Closed hazem3500 closed 4 years ago

hazem3500 commented 4 years ago

when calling getUnit with a non-single property value it gives the error TypeError: Cannot read property '2' of null

"20px 20px 20px 20px".match(/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/) // null
"20px".match(/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/)  // ["20px", "20", "px"]

so I fixed it by checking if the matched array is null

const matchedMeasurement = measurement.match(/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/);
return matchedMeasurement ? matchedMeasurement[2] : null;
codecov-io commented 4 years ago

Codecov Report

Merging #5 into master will increase coverage by 0.04%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
+ Coverage   99.18%   99.22%   +0.04%     
==========================================
  Files           3        3              
  Lines         122      129       +7     
  Branches       15       15              
==========================================
+ Hits          121      128       +7     
  Misses          1        1
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) :arrow_up:

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 69f1239...36224dc. Read the comment docs.

hazem3500 commented 4 years ago

Hello @galacemiguel 👋, I was wondering why this pull request didn't get merged yet? should I elaborate more on what this pull request is fixing?

galacemiguel commented 4 years ago

Hi @hazem3500, sorry I've been quite busy lately. I'll look over this this weekend. Do you mind opening an issue first though? Thanks!