src/vs/workbench/contrib/url/common/urlGlob.ts/doUrlMatch
const doUrlMatch = (
	memo: (boolean | undefined)[][],
	url: string,
	globUrl: string,
	urlOffset: number,
	globUrlOffset: number,
): boolean => {
	if (memo[urlOffset]?.[globUrlOffset] !== undefined) {
		return memo[urlOffset][globUrlOffset]!;
	}

	const options = [];

	// Endgame.
	// Fully exact match
	if (urlOffset === url.length) {
		return globUrlOffset === globUrl.length;
	}

	// Some path remaining in url
	if (globUrlOffset === globUrl.length) {
		const remaining = url.slice(urlOffset);
		return remaining[0] === '/';
	}

	if (url[urlOffset] === globUrl[globUrlOffset]) {
		// Exact match.
		options.push(doUrlMatch(memo, url, globUrl, urlOffset + 1, globUrlOffset + 1));
	}

	if (globUrl[globUrlOffset] + globUrl[globUrlOffset + 1] === '*.') {
		// Any subdomain match. Either consume one thing that's not a / or : and don't advance base or consume nothing and do.
		if (!['/', ':'].includes(url[urlOffset])) {
			options.push(doUrlMatch(memo, url, globUrl, urlOffset + 1, globUrlOffset));
		}
		options.push(doUrlMatch(memo, url, globUrl, urlOffset, globUrlOffset + 2));
	}

	if (globUrl[globUrlOffset] === '*') {
		// Any match. Either consume one thing and don't advance base or consume nothing and do.
		if (urlOffset + 1 === url.length) {
			// If we're at the end of the input url consume one from both.
			options.push(doUrlMatch(memo, url, globUrl, urlOffset + 1, globUrlOffset + 1));
		} else {
			options.push(doUrlMatch(memo, url, globUrl, urlOffset + 1, globUrlOffset));
		}
		options.push(doUrlMatch(memo, url, globUrl, urlOffset, globUrlOffset + 1));
	}

	if (globUrl[globUrlOffset] + globUrl[globUrlOffset + 1] === ':*') {
		// any port match. Consume a port if it exists otherwise nothing. Always comsume the base.
		if (url[urlOffset] === ':') {
			let endPortIndex = urlOffset + 1;
			do { endPortIndex++; } while (/[0-9]/.test(url[endPortIndex]));
			options.push(doUrlMatch(memo, url, globUrl, endPortIndex, globUrlOffset + 2));
		} else {
			options.push(doUrlMatch(memo, url, globUrl, urlOffset, globUrlOffset + 2));
		}
	}

	return (memo[urlOffset][globUrlOffset] = options.some(a => a === true));
};