浏览代码

Fix android special case

Trevor Elliott 3 年之前
父节点
当前提交
b7b8fc3f02
共有 1 个文件被更改,包括 9 次插入7 次删除
  1. 9 7
      lc/app.py

+ 9 - 7
lc/app.py

@@ -303,14 +303,16 @@ class AddLink(Endpoint):
         if not self.user:
             raise e.LCRedirect("/login")
 
-        url = flask.request.args.get("text", None)
-        name = flask.request.args.get("name", None)
-        text = flask.request.args.get("text", None)
+
+        args = flask.request.args.copy()
 
         # Android sets the text field to the url only
-        if url is None and name is None and text is not None:
-            args = f"url={text}"
-        else:
-            args = "&".join(f"{key}={value}" for key, value in flask.request.args.items())
+        url = args.get("url", None)
+        text = args.get("text", "")
+        if url is None and text.startswith("http"):
+            args["url"] = text
+            del args['text']
+
+        args = "&".join(f"{key}={value}" for key, value in args.items())
 
         raise e.LCRedirect(f"/u/{self.user.name}/l?{args}")