File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -934,21 +934,28 @@ class Scanner {
934934
935935 _skipBlanks ();
936936
937+ var prefix = '' ;
938+
937939 /// Both tag uri and local tags can be used as prefixes.
938940 ///
939941 /// See: https://yaml.org/spec/1.2.2/#6822-tag-prefixes
940- var prefix = _scanner.peekChar () == EXCLAMATION
941- ? _scanTagHandle (directive: true , isGlobalTagPrefix: true ).tagHandle
942- : '' ;
942+ if (_scanner.peekChar () == EXCLAMATION ) {
943+ prefix = _scanTagHandle (
944+ directive: true ,
945+ isGlobalTagPrefix: true ,
946+ ).tagHandle;
947+ } else {
948+ prefix = _scanTagUri ();
943949
944- prefix += _scanTagUri (); // Readability's sake
950+ if (prefix.isEmpty) {
951+ throw YamlException (
952+ 'Expected a non-empty global tag prefix' ,
953+ _scanner.emptySpan,
954+ );
955+ }
956+ }
945957
946- if (prefix.isEmpty) {
947- throw YamlException (
948- 'Expected a non-empty global tag prefix' ,
949- _scanner.emptySpan,
950- );
951- } else if (! _isBlankOrEnd) {
958+ if (! _isBlankOrEnd) {
952959 throw YamlException ('Expected whitespace.' , _scanner.emptySpan);
953960 }
954961
You can’t perform that action at this time.
0 commit comments