FIX: prevents time sniffer to match a date starting with the year
This commit is contained in:
parent
f7c2903096
commit
4677307e74
|
@ -312,7 +312,7 @@ class TimeSniffer
|
|||
end
|
||||
|
||||
DATE_SEPARATOR = /[-\/]/
|
||||
DATE_REGEX = /(\d{1,2})#{DATE_SEPARATOR}(\d{1,2})#{DATE_SEPARATOR}(\d{2,4})/
|
||||
DATE_REGEX = /((?:^|\s)\d{1,2})#{DATE_SEPARATOR}(\d{1,2})#{DATE_SEPARATOR}(\d{2,4})/
|
||||
|
||||
matcher(:date, DATE_REGEX) do |m|
|
||||
Parser.new(input, @context).parse_range
|
||||
|
|
|
@ -208,4 +208,9 @@ describe TimeSniffer do
|
|||
it "should not find a time in random numbers and an emoji" do
|
||||
expect_parsed_as_nil("15😊00")
|
||||
end
|
||||
|
||||
it "shouldnt match a date starting with the year" do
|
||||
expect_parsed_as_nil("2020-03-27")
|
||||
expect_parsed_as_nil("foo 2020-03-27")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue