import {resolve} from "path";

export default function (filename, regexps, root) {
	for(let redirectPair of regexps) {
		if(redirectPair[0].test(filename)) {
			console.log("FOUND MATCH", redirectPair[0]);
			return resolve(root, redirectPair[1]);
		}
	}
	
	return null;
}
@@ -118,26 +118,54 @@
 %7B%0A%09%09
-if(redirectPair%5B0%5D
+const regexp = redirectPair%5B0%5D;%0A%09%09%0A%09%09if(regexp
 .tes
@@ -215,23 +215,381 @@
 , re
-directPair%5B0%5D);
+gexp);%0A%09%09%09let redirect = redirectPair%5B1%5D;%0A%09%09%09%0A%09%09%09// if redirect is of %22different/path/$1.js%22 form%0A%09%09%09if(/%5C$%5Cd/.test(redirect)) %7B%0A%09%09%09%09// %22abs/path/to/path/lib.js%22.match(/path/(%5Cw+).js$/)%5B0%5D -%3E%0A%09%09%09%09// %22path/lib.js%22.replace(/path/(%5Cw+).js$/, %22different/path/$1.js%22) -%3E%0A%09%09%09%09// %22different/path/lib.js%22%0A%09%09%09%09redirect = filename.match(regexp)%5B0%5D.replace(regexp, redirect);%0A%09%09%09%7D%0A%09%09%09
 %0A%09%09%09
@@ -617,23 +617,16 @@
 redirect
-Pair%5B1%5D
 );%0A%09%09%7D%0A%09

Allow to use groups ($1) in redirect target