Skip to content

Commit 1006a41

Browse files
committed
Normalize language tags to lowercase, Closes comunica/comunica#1469
1 parent 35a7140 commit 1006a41

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class Util {
203203
}
204204
}
205205
}
206-
return this.dataFactory.literal(literal, activeTag.datatype || activeTag.language);
206+
return this.dataFactory.literal(literal, activeTag.datatype || activeTag.language?.toLowerCase());
207207
}
208208

209209
/**

test/Util-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ describe('Util', () => {
509509
.toEqualRdfTerm(DF.literal('abc', 'en-us'));
510510
});
511511

512+
it('should create case-insensitive language literals', async () => {
513+
const activeTag: any = {
514+
language: 'EN-US',
515+
};
516+
return expect(util.createLiteral('abc', activeTag))
517+
.toEqualRdfTerm(DF.literal('abc', 'en-us'));
518+
});
519+
512520
it('should give preference to datatype literals over language literals', async () => {
513521
const activeTag: any = {
514522
datatype: DF.namedNode('http://example.org/datatype'),

0 commit comments

Comments
 (0)