n3 2.7.8 → 2.7.9

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/lib/N3Lexer.js CHANGED
@@ -498,9 +498,11 @@ class N3Lexer {
498
498
  _parseLiteral(input) {
499
499
  // Ensure we have enough lookahead to identify triple-quoted strings
500
500
  if (input.length >= 3) {
501
- // Identify the opening quote(s)
502
- const opening = input.match(/^(?:"""|"|'''|'|)/)[0];
503
- const openingLength = opening.length;
501
+ // The caller has already identified a single or double quote.
502
+ const quote = input[0];
503
+ const openingLength = input[1] === quote && input[2] === quote ? 3 : 1;
504
+ let opening = quote;
505
+ if (openingLength === 3) opening = quote === '"' ? '"""' : "'''";
504
506
 
505
507
  // Find the next candidate closing quotes
506
508
  let closingPos = Math.max(this._literalClosingPos, openingLength);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.7.8",
3
+ "version": "2.7.9",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/N3Lexer.js CHANGED
@@ -524,9 +524,12 @@ export default class N3Lexer {
524
524
  _parseLiteral(input) {
525
525
  // Ensure we have enough lookahead to identify triple-quoted strings
526
526
  if (input.length >= 3) {
527
- // Identify the opening quote(s)
528
- const opening = input.match(/^(?:"""|"|'''|'|)/)[0];
529
- const openingLength = opening.length;
527
+ // The caller has already identified a single or double quote.
528
+ const quote = input[0];
529
+ const openingLength = input[1] === quote && input[2] === quote ? 3 : 1;
530
+ let opening = quote;
531
+ if (openingLength === 3)
532
+ opening = quote === '"' ? '"""' : "'''";
530
533
 
531
534
  // Find the next candidate closing quotes
532
535
  let closingPos = Math.max(this._literalClosingPos, openingLength);