Skip to content

Strings with '%' symbols which aren't token placeholders don't format correctly #2

@lawmaestro

Description

@lawmaestro

For instance the following:
"%s 0% fat Greek style yogurt"
when formatted with:
"60ml"
should ideally result in:
"60ml 0% fat Greek style yogurt"
Instead the outcome is nil

I've taken a look over the code and this could be fixed by tweaking line 587 in Sprinter.swift:
if first == "%" { break }
to become:

if first == "%" {
  if string.last == nil || string.last == " " {
    break
  }
}

I've tested this locally and all unit tests pass with the change (as well as this new case). I'm happy to create a PR? Let me know, cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions