Skip to content

Commit d48c971

Browse files
committed
improve url regexes
1 parent c1bed28 commit d48c971

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/core/file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class File {
2424
// Only supported in Solidity
2525
return callback(null, content);
2626
}
27-
const regex = /import ["|']([a-zA-Z0-9_\-.\\\/:]+)";/g;
27+
const regex = /import ["|']([-a-zA-Z0-9@:%_+.~#?&\/=]+)["|'];/g;
2828
let matches;
2929
const filesToDownload = [];
3030
const pathWithoutFile = path.dirname(self.path);

lib/utils/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function getExternalContractUrl(file) {
148148
// [4] path
149149
// [5] branch
150150
const match = file.match(
151-
/(git:\/\/)?github\.[a-z]+\/([a-zA-Z0-9_\-.]+)\/([a-zA-Z0-9_\-]+)\/([a-zA-Z0-9_\-\/.]+)#?([a-zA-Z0-1_\-.]*)?/
151+
/(git:\/\/)?github\.[a-z]+\/([-a-zA-Z0-9@:%_+.~#?&=]+)\/([-a-zA-Z0-9@:%_+.~#?&=]+)\/([-a-zA-Z0-9@:%_+.~?\/&=]+)#?([a-zA-Z0-1\/_.-]*)?/
152152
);
153153
if (!match) {
154154
console.error(MALFORMED_ERROR + file);
@@ -165,7 +165,7 @@ function getExternalContractUrl(file) {
165165
return null;
166166
}
167167
const match = url.match(
168-
/\.[a-z]+\/([a-zA-Z0-9_\-\/.]+)/
168+
/\.[a-z]+\/([-a-zA-Z0-9@:%_+.~#?&\/=]+)/
169169
);
170170
return {
171171
url,
File renamed without changes.

0 commit comments

Comments
 (0)