File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,12 +125,12 @@ def decode(urn):
125125 """
126126 segments = [unquote_plus (p ) for p in urn .split (":" )]
127127
128- if len (segments ) < 3 :
129- raise URNValidationError ("Invalid URN: missing namespace or object type." )
130-
131128 if not segments [0 ] == ("urn" ):
132129 raise URNValidationError ("Invalid URN prefix. Expected 'urn'." )
133130
131+ if len (segments ) < 3 :
132+ raise URNValidationError ("Invalid URN: missing namespace or object type." )
133+
134134 if not segments [1 ] == ("dje" ):
135135 raise URNValidationError ("Invalid URN namespace. Expected 'dje'." )
136136
Original file line number Diff line number Diff line change @@ -148,3 +148,9 @@ def test_truncated_urns_raise_validation_error(self):
148148 with self .subTest (value = value ):
149149 with self .assertRaises (urn .URNValidationError ):
150150 urn .decode (value )
151+
152+
153+ class InvalidPrefixTestCase (unittest .TestCase ):
154+ def test_short_non_urn_keeps_prefix_error (self ):
155+ with self .assertRaisesRegex (urn .URNValidationError , "Invalid URN prefix" ):
156+ urn .decode ("x" )
You can’t perform that action at this time.
0 commit comments