0

In a bookmarking app. in Bottle I'm trying to capture a link which is appended to a URL.

But when I'm trying to send a YouTube URL, eg.

http://myapp.com/bookmark/https://www.youtube.com/watch?v=6ZOPGKFsTzI

Even the route

@route("/bookmark/<url:re:.+>")
def save(url) :
    ...

won't capture it.

It captures the https://www.youtube.com/watch but stops at the ?

Any ideas on a pattern to match this?

interstar
  • 26,048
  • 36
  • 112
  • 180
  • `'http://myapp.com/bookmark/https://www.youtube.com/watch?v=6ZOPGKFsTzI'.split('/bookmark/')[1]` – whackamadoodle3000 Aug 11 '17 at 16:00
  • I'm not processing the string manually. This is in Bottle.routes. So that is being done for me behind the scenes. That's why I can't, for example, transform the string before it goes into the regex test. – interstar Aug 11 '17 at 16:07
  • Your example url is, arguably, flawed. At a minimum, the question mark should be escaped, to distinguish myapps.com's args from youtube.com's args. Some [useful discussion is here](https://stackoverflow.com/questions/2322764/what-characters-must-be-escaped-in-an-http-query-string) and elsewhere. – ron rothman Aug 14 '17 at 01:37

1 Answers1

1

The ?... part is likely not considered part of the url by the Bottle framework, but as part of the query string.

You can set a route for bookmark/.*, and then access the request object to get the complete string.

linden2015
  • 887
  • 7
  • 9
  • You've got the right idea, but to be precise: the question mark is indeed a part of the url; it delineates the _path_ component from the _query string_ component. – ron rothman Aug 14 '17 at 01:41