Mercurial > repo
comparison bin/raw-url @ 10317:024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
author | HackBot |
---|---|
date | Sat, 18 Feb 2017 19:02:24 +0000 |
parents | 5a4571b62410 |
children | bb65cc75888c |
comparison
equal
deleted
inserted
replaced
10316:cfa55b232b54 | 10317:024b7442d847 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 import sys, urllib | 2 import sys, os.path, re, urllib |
3 if len(sys.argv) <= 1: | 3 if len(sys.argv) <= 1: |
4 print "http://codu.org/projects/hackbot/fshg/" | 4 print "http://hackego.esolangs.org/fshg/" |
5 else: | 5 else: |
6 print ("http://codu.org/projects/hackbot/fshg/index.cgi/raw-file/tip/" + | 6 f = os.path.abspath(sys.argv[1]) |
7 urllib.quote(sys.argv[1])) | 7 f = re.sub(r"^/+hackenv/", "", f) |
8 if re.match(r"/|\.hg(?:/|$)",f): | |
9 sys.exit("File is outside web-viewable filesystem repository.") | |
10 elif re.match(r"tmp(?:/|$)",f): | |
11 print ("http://hackego.esolangs.org/" + urllib.quote(f)) | |
12 else: | |
13 print ("http://hackego.esolangs.org/fshg/index.cgi/raw-file/tip/" + | |
14 urllib.quote(f)) |