Skip to content

Commit

Permalink
Add more error cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jan 22, 2024
1 parent 91fc19b commit e3ba79f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions context-file-generator/bin/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ function replaceCommonContextURLs(text) {
}

function addEntry(text, type, key, uri, value, expand) {

// Simple context creator unable to deal with JSON-LD edge cases.
if (key.includes(':')){
console.error(`Unable to process file. Attribute contains colons ${key}`)
process.exit(1);
} else if (key.includes('/')){
console.error(`Unable to process file. Attribute contains slashes ${key}`)
process.exit(1);
} else if (key.includes(' ')){
console.error(`Unable to process file. Attribute contains spaces ${key}`)
process.exit(1);
}

if (expand) {
if (type === 'Property' || type === 'GeoProperty' || type === 'LanguageProperty') {
let entry;
Expand Down

0 comments on commit e3ba79f

Please sign in to comment.