File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -585,8 +585,8 @@ export default class N3Parser {
585585 break ;
586586 // Create a language-tagged string
587587 case 'langcode' :
588- if ( token . value . length > 8 )
589- return this . _error ( 'Detected language tag of length larger than 8' , token ) ;
588+ if ( token . value . split ( '-' ) . some ( t => t . length > 8 ) )
589+ return this . _error ( 'Detected language tag with subtag longer than 8 characters ' , token ) ;
590590 literal = this . _factory . literal ( this . _literalValue , token . value ) ;
591591 this . _literalLanguage = token . value ;
592592 token = null ;
Original file line number Diff line number Diff line change @@ -170,10 +170,17 @@ describe('Parser', () => {
170170 } ) ,
171171 ) ;
172172
173+ const validLanguageTags = [ 'en' , 'en-US' , 'be-tarask' ] ;
174+ it . each ( validLanguageTags ) (
175+ 'should parse a triple with a valid language tag (%s)' , ( tag , done ) => {
176+ return shouldParse ( `<a> <b> "Hello"@${ tag } .` ,
177+ [ 'a' , 'b' , `"Hello"@${ tag } ` ] ) ( done ) ;
178+ } ) ;
179+
173180 it (
174- 'should error on a triple with a literal with language tag of length > 8 ' ,
175- shouldNotParse ( '<a> <b> "Hello"@cantbethislong.' ,
176- 'Detected language tag of length larger than 8 on line 1.' , {
181+ 'should error on a triple where a literal has a language subtag longer than 8 characters (single subtag) ' ,
182+ shouldNotParse ( '<a> <b> "Hello"@cantbethislong.' ,
183+ 'Detected language tag with subtag longer than 8 characters on line 1.' , {
177184 line : 1 ,
178185 previousToken : {
179186 line : 1 ,
@@ -3128,7 +3135,7 @@ describe('Parser', () => {
31283135 @prefix : <http://example.com/> .
31293136 [ :friend [
31303137 :name "Thomas" ;
3131- ]
3138+ ]
31323139 ] .
31333140 ` ) ;
31343141
You can’t perform that action at this time.
0 commit comments