Quellcode durchsuchen

Fix android special case

Trevor Elliott vor 3 Jahren
Ursprung
Commit
b7b8fc3f02
1 geänderte Dateien mit 9 neuen und 7 gelöschten Zeilen
  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}")