From 51bcbfbc97e8fe33c1b6ec34b70119e76c849f99 Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Thu, 16 Jun 2011 16:26:45 -0700 Subject: [PATCH] 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 --- r2/example.ini | 3 +++ r2/r2/lib/app_globals.py | 3 ++- r2/r2/models/link.py | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) mode change 100644 => 100755 r2/example.ini mode change 100644 => 100755 r2/r2/lib/app_globals.py mode change 100644 => 100755 r2/r2/models/link.py diff --git a/r2/example.ini b/r2/example.ini old mode 100644 new mode 100755 index 593335219e..e999790ab9 --- a/r2/example.ini +++ b/r2/example.ini @@ -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 diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py old mode 100644 new mode 100755 index ac3a710b72..ac4b5ccf6a --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -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}, diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py old mode 100644 new mode 100755 index 69e70958a8..cc7e45348e --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -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,