Skip to content

Commit a875194

Browse files
committed
Also allow executing from files in projects on github
1 parent 8dd8ee7 commit a875194

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/EvalbotExecuter.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ sub run {
8585
my $page = `curl -s $program`;
8686
$page =~ /href="\/raw([^"]+)"/;
8787
if ($1) { $program = decode_utf8 `curl -s https://raw.github.com/gist$1` } else { return 'gist not found' };
88+
} elsif ($program =~ /^https:\/\/github\.com\/([^\/]+\/[^\/]+)\/blob\/([^\/]+\/[^\/].*)$/) {
89+
my ($project, $file) = ($1, $2);
90+
my $page = `curl -s $program`;
91+
if ($page =~ /href="\/$project\/raw\/$file"/) {
92+
$program = decode_utf8 `curl -s https://raw.github.com/$project/$file`
93+
} else {
94+
return 'file not found'
95+
};
8896
}
8997
my $response = _fork_and_eval($program, $executer, $ename);
9098
if (!length $response){

0 commit comments

Comments
 (0)