Method _key_from_url() now returns case sensitive results for special domains (e.g. imgur.com, youtube.com). They are defined as case_sensitive_domains in the .ini file

This commit is contained in:
Brian Simpson
2011-06-16 16:26:45 -07:00
parent 1b030c310d
commit 51bcbfbc97
3 changed files with 12 additions and 2 deletions

3
r2/example.ini Normal file → Executable file
View File

@@ -375,6 +375,9 @@ share_reply = noreply@reddit.com
# feedback email
feedback_email = reddit@gmail.com
# Special case sensitive domains
case_sensitive_domains = i.imgur.com, youtube.com
[server:main]
use = egg:Paste#http
host = 0.0.0.0

3
r2/r2/lib/app_globals.py Normal file → Executable file
View File

@@ -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},

8
r2/r2/models/link.py Normal file → Executable file
View File

@@ -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,