ada icon indicating copy to clipboard operation
ada copied to clipboard

feat: adds urlpattern to ada

Open miguelteixeiraa opened this issue 2 years ago • 5 comments

TL;DR

WIP!


So i started to implement https://wicg.github.io/urlpattern/ Seems that this is an work-in-progress spec, so maybe we'll have some freestyle stuff along the way of the implementation. I'm using https://github.com/kenchris/urlpattern-polyfill and https://github.com/denoland/rust-urlpattern as references.

Don't know if there is a "right way" to do this, but I get the unicode identifier start/part ranges using the script:

"use strict";

const fs = require("fs");

const regexIdentifierStart = /[$_\p{ID_Start}]/u;

function isValidIdStart(num) {
  const c = String.fromCharCode(num);
  return regexIdentifierStart.test(c);
}

const validRanges = [];
let start = null;

for (let c = 256; c < 0x10ffff; c++) {
  const isValid = isValidIdStart(c);
  if (isValid && start === null) {
    start = c;
  } else if (!isValid && start !== null) {
    validRanges.push([start, c - 1]);
    start = null;
  }
}

const writeRangeInFile = (filename, ranges) => {
  let file = "";
  for (const [base, upper] of ranges) {
    file += `\{${base}, ${upper}\},\n`;
  }
  fs.writeFile(filename, file, (err) => {});
};

console.log(validRanges.length);

writeRangeInFile("id_start_ranges.txt", validRanges);

++ something similar for the identifier-part with the regex /[$_\u200C\u200D\p{ID_Continue}]/u I got those regexes in https://github.com/kenchris/urlpattern-polyfill/blob/main/src/path-to-regex-modified.ts#LL70C1-L70C50

Then I used the ranges to create bitwise masks in the unicode.cpp.

Nothing is tested yet

It will took some time to finish!

ref https://github.com/nodejs/node/issues/40844

miguelteixeiraa avatar May 09 '23 20:05 miguelteixeiraa

Is there any way to crank 🔧 this up for https://github.com/nodejs/node/issues/51060 needs? 🤔

bricss avatar Dec 05 '23 19:12 bricss

Houston, do you read me? 📡

bricss avatar Jan 15 '24 22:01 bricss

@bricss Are you available to help push this forward?

lemire avatar Jan 15 '24 22:01 lemire

Yes, with only one exception, I don't have big/deep experience with C++ coding 🤷‍♂️ atm 🙄

bricss avatar Jan 15 '24 23:01 bricss

@bricss Lack of knowledge of C++ could be a problem.

lemire avatar Jan 15 '24 23:01 lemire