Skip to content

Commit

Permalink
Method _key_from_url() now returns case sensitive results for special…
Browse files Browse the repository at this point in the history
… domains (e.g. imgur.com, youtube.com). They are defined as case_sensitive_domains in the .ini file
  • Loading branch information
bsimpson63 committed Jun 20, 2011
1 parent 1b030c3 commit 51bcbfb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions r2/example.ini
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ share_reply = [email protected]
# feedback email
feedback_email = [email protected]

# Special case sensitive domains
case_sensitive_domains = i.imgur.com, youtube.com

[server:main]
use = egg:Paste#http
host = 0.0.0.0
Expand Down
3 changes: 2 additions & 1 deletion r2/r2/lib/app_globals.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class Globals(object):
'authorized_cnames',
'hardcache_categories',
'proxy_addr',
'allowed_pay_countries']
'allowed_pay_countries',
'case_sensitive_domains']

choice_props = {'cassandra_rcl': {'ONE': CL_ONE,
'QUORUM': CL_QUORUM},
Expand Down
8 changes: 7 additions & 1 deletion r2/r2/models/link.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,13 @@ class LinksByUrl(tdb_cassandra.View):

@classmethod
def _key_from_url(cls, url):
keyurl = _force_utf8(UrlParser.base_url(url.lower()))
if not utils.domain(url) in g.case_sensitive_domains:
keyurl = _force_utf8(UrlParser.base_url(url.lower()))
else:
# Convert only hostname to lowercase
up = UrlParser(url)
up.hostname = up.hostname.lower()
keyurl = _force_utf8(UrlParser.base_url(up.unparse()))
return keyurl

# Note that there are no instances of PromotedLink or LinkCompressed,
Expand Down

0 comments on commit 51bcbfb

Please sign in to comment.