n3 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/n3.min.js +1 -1
- package/lib/N3DataFactory.js +5 -4
- package/package.json +1 -1
- package/src/N3DataFactory.js +5 -4
package/lib/N3DataFactory.js
CHANGED
|
@@ -106,10 +106,11 @@ class Literal extends Term {
|
|
|
106
106
|
|
|
107
107
|
// ### The direction of this literal
|
|
108
108
|
get direction() {
|
|
109
|
-
// Find the last double dash (e.g., '"abc"@en-us--ltr')
|
|
109
|
+
// Find the last double dash after the closing quote (e.g., '"abc"@en-us--ltr')
|
|
110
110
|
const id = this.id;
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const endPos = id.lastIndexOf('"');
|
|
112
|
+
const dirPos = id.lastIndexOf('--');
|
|
113
|
+
return dirPos > endPos && dirPos + 2 < id.length ? id.substr(dirPos + 2).toLowerCase() : '';
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
// ### The datatype IRI of this literal
|
|
@@ -364,7 +365,7 @@ function literal(value, languageOrDataType) {
|
|
|
364
365
|
|
|
365
366
|
// Create a language-tagged string with base direction
|
|
366
367
|
if (languageOrDataType !== undefined && !('termType' in languageOrDataType)) {
|
|
367
|
-
return new Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}
|
|
368
|
+
return new Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}${languageOrDataType.direction ? `--${languageOrDataType.direction.toLowerCase()}` : ''}`);
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
// Automatically determine datatype for booleans and numbers
|
package/package.json
CHANGED
package/src/N3DataFactory.js
CHANGED
|
@@ -95,10 +95,11 @@ export class Literal extends Term {
|
|
|
95
95
|
|
|
96
96
|
// ### The direction of this literal
|
|
97
97
|
get direction() {
|
|
98
|
-
// Find the last double dash (e.g., '"abc"@en-us--ltr')
|
|
98
|
+
// Find the last double dash after the closing quote (e.g., '"abc"@en-us--ltr')
|
|
99
99
|
const id = this.id;
|
|
100
|
-
const
|
|
101
|
-
|
|
100
|
+
const endPos = id.lastIndexOf('"');
|
|
101
|
+
const dirPos = id.lastIndexOf('--');
|
|
102
|
+
return dirPos > endPos && dirPos + 2 < id.length ? id.substr(dirPos + 2).toLowerCase() : '';
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// ### The datatype IRI of this literal
|
|
@@ -376,7 +377,7 @@ function literal(value, languageOrDataType) {
|
|
|
376
377
|
|
|
377
378
|
// Create a language-tagged string with base direction
|
|
378
379
|
if (languageOrDataType !== undefined && !('termType' in languageOrDataType)) {
|
|
379
|
-
return new Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}
|
|
380
|
+
return new Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}${languageOrDataType.direction ? `--${languageOrDataType.direction.toLowerCase()}` : ''}`);
|
|
380
381
|
}
|
|
381
382
|
|
|
382
383
|
// Automatically determine datatype for booleans and numbers
|