Skip to content

Commit 08fbfc9

Browse files
committed
Merge pull request #11 from yetanalytics/8_tagged_versions
improved xAPI version regex
2 parents df5ee56 + 59fa49f commit 08fbfc9

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

spec/cljx/xapi_schema/schemata/json_spec.cljx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,20 @@
144144
"1.0.1"
145145
"1.0.2"
146146
"1.0.3"
147+
"1.0.3-rc1"
148+
"1.0.0-alpha"
149+
"1.0.0-alpha.1"
150+
"1.0.0-0.3.7"
151+
"1.0.0-x.7.z.92"
147152
:bad
148153
"0.9.5"
154+
"1.0." ;; bad semver
155+
"1.0.0-.123"
156+
"1.0.0-..."
157+
"1.0.0-123."
158+
"1.0.0-+"
159+
"1.0.0-+123"
160+
"1.0.0-"
149161
"what's going on?")))
150162

151163
(describe

src/cljx/xapi_schema/schemata/regex.cljx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
(def TimestampRegEx
2525
#"^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)|T23:59:60Z)?)?$")
2626

27+
;; Based on http://www.regexr.com/39s32
2728
(def xAPIVersionRegEx
28-
#"^1\.0\.(\d+)?$")
29+
#"^((1\.0\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$")
2930

3031
(def DurationRegEx
3132
#"^P((\d+([\.,]\d+)?Y)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?W)?(\d+([\.,]\d+)?D)?)?(T(\d+([\.,]\d+)?H)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?S)?)?$")

0 commit comments

Comments
 (0)