Skip to content

Commit

Permalink
Fix path parsing not considering scientific notation (#58)
Browse files Browse the repository at this point in the history
* chore: add github issue icons to gitignore

* fix: account comma space free separation into transform

* fix: consider e notation on path normalization
  • Loading branch information
rafaeltonholo authored Aug 16, 2024
1 parent 5af260c commit 828066e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ integrity-check/
local.properties
.s2c/

github_issue_[0-9]*.svg

.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,9 @@ private fun normalizePath(path: String): String {
continue
}

val isNotENotation = char != 'e'
val isNotClosingCommand = (char.isLetter() && char.lowercaseChar() != PathCommand.Close.value)
val isNegativeSign = (lastChar.isDigit() && char == '-')
val isNegativeSignSeparator = (lastChar.isDigit() && char == '-')
val reachMaximumDotNumbers = dotCount == 2

char.toPathCommand()?.let {
Expand All @@ -506,7 +507,7 @@ private fun normalizePath(path: String): String {
.trimWhitespaceBeforeClose(lastChar, current = char)
.append(
when {
isNotClosingCommand || isNegativeSign || reachMaximumDotNumbers -> {
isNotENotation && (isNotClosingCommand || isNegativeSignSeparator || reachMaximumDotNumbers) -> {
dotCount = resetDotCount(current = char)
" $char"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ value class SvgTransform(val value: String) {
.trim()
.removePrefix("$name(")
.removeSuffix(")")
.split(", ", ", ", " ")
.map { it.toFloat() }
.split(", ", ", ", " ", ",")
.map {
requireNotNull(it.toFloatOrNull()) {
"unable to parse value $it to Float. transform = $value"
}
}

name to values
}
Expand Down

0 comments on commit 828066e

Please sign in to comment.