@@ -25,13 +25,13 @@ const {
2525
2626const {
2727 REGEX_BCP47 ,
28+ REGEX_KEYWORD ,
2829 asArray : _asArray ,
2930 compareShortestLeast : _compareShortestLeast
3031} = require ( './util' ) ;
3132
3233const INITIAL_CONTEXT_CACHE = new Map ( ) ;
3334const INITIAL_CONTEXT_CACHE_MAX_SIZE = 10000 ;
34- const KEYWORD_PATTERN = / ^ @ [ a - z A - Z ] + $ / ;
3535
3636const api = { } ;
3737module . exports = api ;
@@ -492,7 +492,7 @@ api.createTermDefinition = ({
492492 'Invalid JSON-LD syntax; keywords cannot be overridden.' ,
493493 'jsonld.SyntaxError' ,
494494 { code : 'keyword redefinition' , context : localCtx , term} ) ;
495- } else if ( term . match ( KEYWORD_PATTERN ) ) {
495+ } else if ( term . match ( REGEX_KEYWORD ) ) {
496496 if ( options . eventHandler ) {
497497 _handleEvent ( {
498498 event : {
@@ -587,7 +587,7 @@ api.createTermDefinition = ({
587587 'jsonld.SyntaxError' , { code : 'invalid IRI mapping' , context : localCtx } ) ;
588588 }
589589
590- if ( reverse . match ( KEYWORD_PATTERN ) ) {
590+ if ( reverse . match ( REGEX_KEYWORD ) ) {
591591 if ( options . eventHandler ) {
592592 _handleEvent ( {
593593 event : {
@@ -636,7 +636,7 @@ api.createTermDefinition = ({
636636 if ( id === null ) {
637637 // reserve a null term, which may be protected
638638 mapping [ '@id' ] = null ;
639- } else if ( ! api . isKeyword ( id ) && id . match ( KEYWORD_PATTERN ) ) {
639+ } else if ( ! api . isKeyword ( id ) && id . match ( REGEX_KEYWORD ) ) {
640640 if ( options . eventHandler ) {
641641 _handleEvent ( {
642642 event : {
@@ -1019,7 +1019,7 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
10191019 }
10201020
10211021 // ignore non-keyword things that look like a keyword
1022- if ( value . match ( KEYWORD_PATTERN ) ) {
1022+ if ( value . match ( REGEX_KEYWORD ) ) {
10231023 return null ;
10241024 }
10251025
0 commit comments