Skip to content

Commit 74358c2

Browse files
authored
Fix Flaky Test (#91)
1 parent c24abf4 commit 74358c2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/purl/generator.ex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ with {:module, StreamData} <- Code.ensure_loaded(StreamData) do
1010
alias Purl.Generator.Version, as: VersionGenerator
1111

1212
@spec type :: StreamData.t(Purl.type())
13-
def type, do: require_letter_start(string([?a..?z, ?A..?Z, ?0..?9, ?., ?+, ?-], min_length: 1, max_length: 20))
13+
def type do
14+
[?a..?z, ?A..?Z, ?0..?9, ?., ?+, ?-]
15+
|> string(min_length: 1, max_length: 20)
16+
|> require_letter_start()
17+
# Discard Known Types since those have restrictions on segments of the purl
18+
|> filter(fn type ->
19+
case :purl_type_registry.lookup(type) do
20+
%{"$id": "unregistered://" <> _rest} -> true
21+
_known_type -> false
22+
end
23+
end)
24+
end
1425

1526
@spec namespace_segment :: StreamData.t(Purl.namespace_segment())
1627
def namespace_segment, do: filter(string(:printable, min_length: 1, max_length: 50), &(not String.contains?(&1, "/")))

0 commit comments

Comments
 (0)