~robru/friends/limit-notifications

« back to all changes in this revision

Viewing changes to friends/shorteners/base.py

  • Committer: Tarmac
  • Author(s): Robert Bruce Park
  • Date: 2013-03-29 17:23:20 UTC
  • mfrom: (171.1.2 quote-urls)
  • Revision ID: tarmac-20130329172320-cltx95b52kzvj7b8
Properly quote long URLs when submitting them for shortening, so that they don't break in transit.

Approved by Ken VanDine, PS Jenkins bot, Robert Bruce Park.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    ]
21
21
 
22
22
 
 
23
from urllib.parse import quote
 
24
 
23
25
from friends.utils.http import Downloader
24
26
 
25
27
 
29
31
    fqdn = None
30
32
 
31
33
    def shorten(self, url):
32
 
        return Downloader(self.URL_TEMPLATE.format(url)).get_string().rstrip()
 
34
        return Downloader(
 
35
            self.URL_TEMPLATE.format(quote(url, safe=''))).get_string().rstrip()