view bin/url @ 12556:79923443dff9 draft default tip

<Sgeo> ` rm -r /hackenv/pli-1.4.1
author HackEso <hackeso@esolangs.org>
date Thu, 07 May 2026 23:44:20 +0000
parents 3d2024a42bbc
children
line wrap: on
line source

#!/usr/bin/env python3
import sys, os.path, re, urllib.parse
if len(sys.argv) <= 1:
    print("https://hack.esolangs.org/repo/")
else:
    f = os.path.abspath(sys.argv[1])
    f = re.sub(r"^/+hackenv/", "", f)
    if re.match(r"/|\.hg(?:/|$)",f):
        sys.exit("File is outside web-viewable filesystem repository.")
    elif re.match(r"tmp(?:/|$)",f):
        print("https://hack.esolangs.org/" + urllib.parse.quote(f))
    else:
        print("https://hack.esolangs.org/repo/file/tip/" +
            urllib.parse.quote(f))