@@ -25,13 +25,13 @@ const {
25
25
26
26
const {
27
27
REGEX_BCP47 ,
28
+ REGEX_KEYWORD ,
28
29
asArray : _asArray ,
29
30
compareShortestLeast : _compareShortestLeast
30
31
} = require ( './util' ) ;
31
32
32
33
const INITIAL_CONTEXT_CACHE = new Map ( ) ;
33
34
const INITIAL_CONTEXT_CACHE_MAX_SIZE = 10000 ;
34
- const KEYWORD_PATTERN = / ^ @ [ a - z A - Z ] + $ / ;
35
35
36
36
const api = { } ;
37
37
module . exports = api ;
@@ -492,7 +492,7 @@ api.createTermDefinition = ({
492
492
'Invalid JSON-LD syntax; keywords cannot be overridden.' ,
493
493
'jsonld.SyntaxError' ,
494
494
{ code : 'keyword redefinition' , context : localCtx , term} ) ;
495
- } else if ( term . match ( KEYWORD_PATTERN ) ) {
495
+ } else if ( term . match ( REGEX_KEYWORD ) ) {
496
496
if ( options . eventHandler ) {
497
497
_handleEvent ( {
498
498
event : {
@@ -587,7 +587,7 @@ api.createTermDefinition = ({
587
587
'jsonld.SyntaxError' , { code : 'invalid IRI mapping' , context : localCtx } ) ;
588
588
}
589
589
590
- if ( reverse . match ( KEYWORD_PATTERN ) ) {
590
+ if ( reverse . match ( REGEX_KEYWORD ) ) {
591
591
if ( options . eventHandler ) {
592
592
_handleEvent ( {
593
593
event : {
@@ -636,7 +636,7 @@ api.createTermDefinition = ({
636
636
if ( id === null ) {
637
637
// reserve a null term, which may be protected
638
638
mapping [ '@id' ] = null ;
639
- } else if ( ! api . isKeyword ( id ) && id . match ( KEYWORD_PATTERN ) ) {
639
+ } else if ( ! api . isKeyword ( id ) && id . match ( REGEX_KEYWORD ) ) {
640
640
if ( options . eventHandler ) {
641
641
_handleEvent ( {
642
642
event : {
@@ -1019,7 +1019,7 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
1019
1019
}
1020
1020
1021
1021
// ignore non-keyword things that look like a keyword
1022
- if ( value . match ( KEYWORD_PATTERN ) ) {
1022
+ if ( value . match ( REGEX_KEYWORD ) ) {
1023
1023
return null ;
1024
1024
}
1025
1025
0 commit comments