Project

General

Profile

Actions

Keep locator format

Draft. See discussion at #2755

locator       ::= sized-digest hint*

sized-digest  ::= digest size-hint

digest        ::= <32 lowercase hexadecimal digits>

size-hint     ::= "+" [0-9]+

hint          ::= "+" hint-type hint-content

hint-type     ::= [A-Z]+

hint-content  ::= [A-Za-z0-9@_-]*

sign-hint      ::= "+A" <40 lowercase hexadecimal digits> "@" sign-timestamp

sign-timestamp ::= <8 lowercase hexadecimal digits>

Regular expressions

Is it a valid locator?

/^([0-9a-f]{32})\+([0-9]+)(\+[A-Z][-A-Za-z0-9@_]*)*$/

Good examples

(note md5hex("foo") == "acbd18db4cc2f85cedef654fccc4a4d8")

acbd18db4cc2f85cedef654fccc4a4d8+3
acbd18db4cc2f85cedef654fccc4a4d8+3+Z
acbd18db4cc2f85cedef654fccc4a4d8+3+Z+Ada39a3ee5e6b4b0d3255bfef95601890afd80709@53bed294

Bad examples

Why
acbd18db4cc2f85cedef654fccc4a4d8 No size hint
acbd18db4cc2f85cedef654fccc4a4d8+Z+3 Other hint before size hint
acbd18db4cc2f85cedef654fccc4a4d8+3+3 Multiple size hints
acbd18db4cc2f85cedef654fccc4a4d8+3+z Hint does not start with uppercase letter
acbd18db4cc2f85cedef654fccc4a4d8+3+Zfoo*bar Hint contains invalid character *

Updated by Tom Clegg over 5 years ago · 3 revisions