tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

escaped-solidus-character-mixed.js (912B)


      1 // Copyright (C) 2024 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-regexp.escape
      6 description: Escaped U+002F (SOLIDUS) characters (mixed assertions)
      7 info: |
      8  EncodeForRegExpEscape ( c )
      9 
     10  1. If c is matched by SyntaxCharacter or c is U+002F (SOLIDUS), then
     11    a. Return the string-concatenation of 0x005C (REVERSE SOLIDUS) and UTF16EncodeCodePoint(c).
     12 features: [RegExp.escape]
     13 ---*/
     14 
     15 assert.sameValue(RegExp.escape('.a/b'), '\\.a\\/b', 'mixed string with solidus character is escaped correctly');
     16 assert.sameValue(RegExp.escape('/./'), '\\/\\.\\/', 'solidus character is escaped correctly - regexp similar');
     17 assert.sameValue(RegExp.escape('./a\\/*b+c?d^e$f|g{2}h[i]j\\k'), '\\.\\/a\\\\\\/\\*b\\+c\\?d\\^e\\$f\\|g\\{2\\}h\\[i\\]j\\\\k', 'complex string with multiple special characters is escaped correctly');
     18 
     19 reportCompare(0, 0);