@@ -103,7 +103,7 @@ func (parser *tvParser) parsePairFromCreationInfo(tag string, value string) erro
103103
104104// ===== Helper functions =====
105105
106- func extractExternalDocumentReference (value string ) (string , string , string , string , error ) {
106+ func extractExternalDocumentReference (value string ) (common. DocumentID , string , string , string , error ) {
107107 sp := strings .Split (value , " " )
108108 // remove any that are just whitespace
109109 keepSp := []string {}
@@ -114,42 +114,43 @@ func extractExternalDocumentReference(value string) (string, string, string, str
114114 }
115115 }
116116
117- var documentRefID , uri , alg , checksum string
117+ var documentRefID common.DocumentID
118+ var strDocRefID , uri , alg , checksum string
118119
119120 // now, should have 4 items (or 3, if Alg and Checksum were joined)
120121 // and should be able to map them
121122 if len (keepSp ) == 4 {
122- documentRefID = keepSp [0 ]
123+ strDocRefID = keepSp [0 ]
123124 uri = keepSp [1 ]
124125 alg = keepSp [2 ]
125126 // check that colon is present for alg, and remove it
126127 if ! strings .HasSuffix (alg , ":" ) {
127- return "" , "" , "" , "" , fmt .Errorf ("algorithm does not end with colon" )
128+ return common . DocumentID ( "" ) , "" , "" , "" , fmt .Errorf ("algorithm does not end with colon" )
128129 }
129130 alg = strings .TrimSuffix (alg , ":" )
130131 checksum = keepSp [3 ]
131132 } else if len (keepSp ) == 3 {
132- documentRefID = keepSp [0 ]
133+ strDocRefID = keepSp [0 ]
133134 uri = keepSp [1 ]
134135 // split on colon into alg and checksum
135136 parts := strings .SplitN (keepSp [2 ], ":" , 2 )
136137 if len (parts ) != 2 {
137- return "" , "" , "" , "" , fmt .Errorf ("missing colon separator between algorithm and checksum" )
138+ return common . DocumentID ( "" ) , "" , "" , "" , fmt .Errorf ("missing colon separator between algorithm and checksum" )
138139 }
139140 alg = parts [0 ]
140141 checksum = parts [1 ]
141142 } else {
142- return "" , "" , "" , "" , fmt .Errorf ("expected 4 elements, got %d" , len (keepSp ))
143+ return common . DocumentID ( "" ) , "" , "" , "" , fmt .Errorf ("expected 4 elements, got %d" , len (keepSp ))
143144 }
144145
145146 // additionally, we should be able to parse the first element as a
146147 // DocumentRef- ID string, and we should remove that prefix
147- if ! strings .HasPrefix (documentRefID , "DocumentRef-" ) {
148- return "" , "" , "" , "" , fmt .Errorf ("expected first element to have DocumentRef- prefix" )
148+ if ! strings .HasPrefix (strDocRefID , "DocumentRef-" ) {
149+ return common . DocumentID ( "" ) , "" , "" , "" , fmt .Errorf ("expected first element to have DocumentRef- prefix" )
149150 }
150- documentRefID = strings .TrimPrefix (documentRefID , "DocumentRef-" )
151+ documentRefID = common . DocumentID ( strings .TrimPrefix (strDocRefID , "DocumentRef-" ) )
151152 if documentRefID == "" {
152- return "" , "" , "" , "" , fmt .Errorf ("document identifier has nothing after prefix" )
153+ return common . DocumentID ( "" ) , "" , "" , "" , fmt .Errorf ("document identifier has nothing after prefix" )
153154 }
154155
155156 return documentRefID , uri , alg , checksum , nil
0 commit comments