dfd
This commit is contained in:
@@ -34,6 +34,19 @@ class Add_Url(sh.Cmdlet):
|
||||
"""Add URL to file via hash+store backend."""
|
||||
parsed = sh.parse_cmdlet_args(args, self)
|
||||
|
||||
# Compatibility/piping fix:
|
||||
# `SharedArgs.QUERY` is positional in the shared parser, so `add-url <url>`
|
||||
# (and `@N | add-url <url>`) can mistakenly parse the URL into `query`.
|
||||
# If `url` is missing and `query` looks like an http(s) URL, treat it as `url`.
|
||||
try:
|
||||
if (not parsed.get("url")) and isinstance(parsed.get("query"), str):
|
||||
q = str(parsed.get("query") or "").strip()
|
||||
if q.startswith(("http://", "https://")):
|
||||
parsed["url"] = q
|
||||
parsed.pop("query", None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
query_hash = sh.parse_single_hash_query(parsed.get("query"))
|
||||
if parsed.get("query") and not query_hash:
|
||||
log("Error: -query must be of the form hash:<sha256>")
|
||||
|
||||
Reference in New Issue
Block a user