Skip to content

Commit a2e9efe

Browse files
committed
Add "naive" id check
1 parent 38145e1 commit a2e9efe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/scala/org/janalyse/CodeExample.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ object CodeExample {
4141

4242
def apply(file: File): FileCodeExample = {
4343
val content = file.contentAsString
44+
val id = extractValue(content)("id")
45+
val idRE = "[-0-9a-f]+".r
46+
if (id.isDefined) assert(idRE.matches(id.get), s"INVALID UUID: $id for $file")
4447
FileCodeExample(
4548
file = file,
4649
summary = extractValue(content)("summary"),
4750
keywords = extractValueList(content)("keywords"),
4851
publish = extractValueList(content)("publish"),
4952
authors = extractValueList(content)("authors"),
50-
uuid = extractValue(content)("id"),
53+
uuid = id,
5154
)
5255
}
5356
}

0 commit comments

Comments
 (0)