tor-browser

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

named-capture-proxy.js (531B)


      1 var access_log = "";
      2 const handler = {
      3    get: function(obj, prop) {
      4        access_log += prop + ",";
      5        return prop in obj ? obj[prop] : "<filled by proxy>";
      6    }
      7 };
      8 
      9 class ProxiedGroupRegExp extends RegExp {
     10    exec(s) {
     11        var result = super.exec(s);
     12        if (result) {
     13            result.groups = new Proxy(result.groups, handler);
     14        }
     15        return result;
     16    }
     17 }
     18 
     19 let re = new ProxiedGroupRegExp("(?<x>.)");
     20 assertEq("a".replace(re, "$<x> $<y>"), "a <filled by proxy>");
     21 assertEq(access_log, "x,y,")