tolu / ISO8601-duration

Node/Js-module for parsing and making sense of ISO8601-durations
92 stars 10 forks source link

P1111111111 is valid and shouldn't be #13

Closed keenahn closed 2 years ago

keenahn commented 5 years ago
nesh> const { parse } = require('iso8601-duration')
undefined
nesh> parse('P1111111111')
{ weeks: 0,
  years: 0,
  months: 0,
  days: 0,
  hours: 0,
  minutes: 0,
  seconds: 0 }
keenahn commented 5 years ago

Same with PD or even just P

nesh> parse('PD')
{ weeks: 0,
  years: 0,
  months: 0,
  days: 0,
  hours: 0,
  minutes: 0,
  seconds: 0 }
nesh> parse('P')
{ weeks: 0,
  years: 0,
  months: 0,
  days: 0,
  hours: 0,
  minutes: 0,
  seconds: 0 }

These should throw IMO

hlerebours commented 3 years ago

I agree that there is a bug here. Or two:

=> Any string containing a "P" is considered a valid ISO duration, which is obviously not true (is "API" a valid duration?).