improve url regexes

This commit is contained in:
Jonathan Rainville 2018-04-20 12:04:27 -04:00
parent c1bed28c00
commit d48c971471
3 changed files with 3 additions and 3 deletions

View File

@ -24,7 +24,7 @@ class File {
// Only supported in Solidity // Only supported in Solidity
return callback(null, content); return callback(null, content);
} }
const regex = /import ["|']([a-zA-Z0-9_\-.\\\/:]+)";/g; const regex = /import ["|']([-a-zA-Z0-9@:%_+.~#?&\/=]+)["|'];/g;
let matches; let matches;
const filesToDownload = []; const filesToDownload = [];
const pathWithoutFile = path.dirname(self.path); const pathWithoutFile = path.dirname(self.path);

View File

@ -148,7 +148,7 @@ function getExternalContractUrl(file) {
// [4] path // [4] path
// [5] branch // [5] branch
const match = file.match( const match = file.match(
/(git:\/\/)?github\.[a-z]+\/([a-zA-Z0-9_\-.]+)\/([a-zA-Z0-9_\-]+)\/([a-zA-Z0-9_\-\/.]+)#?([a-zA-Z0-1_\-.]*)?/ /(git:\/\/)?github\.[a-z]+\/([-a-zA-Z0-9@:%_+.~#?&=]+)\/([-a-zA-Z0-9@:%_+.~#?&=]+)\/([-a-zA-Z0-9@:%_+.~?\/&=]+)#?([a-zA-Z0-1\/_.-]*)?/
); );
if (!match) { if (!match) {
console.error(MALFORMED_ERROR + file); console.error(MALFORMED_ERROR + file);
@ -165,7 +165,7 @@ function getExternalContractUrl(file) {
return null; return null;
} }
const match = url.match( const match = url.match(
/\.[a-z]+\/([a-zA-Z0-9_\-\/.]+)/ /\.[a-z]+\/([-a-zA-Z0-9@:%_+.~#?&\/=]+)/
); );
return { return {
url, url,