diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-08-23 10:23:51 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-08-23 10:23:51 -0400 |
commit | b14450451180941e4c00bf5a479610796b57fd05 (patch) | |
tree | ca16b8fff60b73bdf73f313fa73c31a48df365f8 /askbot/utils | |
parent | 17eafa2d31bfc9f2bad2095be6cfee5f36c7aa55 (diff) | |
download | askbot-b14450451180941e4c00bf5a479610796b57fd05.tar.gz askbot-b14450451180941e4c00bf5a479610796b57fd05.tar.bz2 askbot-b14450451180941e4c00bf5a479610796b57fd05.zip |
added tinymce config checker for the settings.py
Diffstat (limited to 'askbot/utils')
-rw-r--r-- | askbot/utils/url_utils.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/askbot/utils/url_utils.py b/askbot/utils/url_utils.py index 6027d096..c58239c5 100644 --- a/askbot/utils/url_utils.py +++ b/askbot/utils/url_utils.py @@ -1,3 +1,4 @@ +import os import urlparse from django.core.urlresolvers import reverse from django.conf import settings @@ -13,6 +14,38 @@ def strip_path(url): ) ) +def append_trailing_slash(urlpath): + """if path is empty - returns slash + if not and path does not end with the slash + appends it + """ + if urlpath == '': + return '/' + elif not urlpath.endswith('/'): + return urlpath + '/' + return urlpath + +def urls_equal(url1, url2, ignore_trailing_slash=False): + """True, if urls are equal""" + purl1 = urlparse.urlparse(url1) + purl2 = urlparse.urlparse(url2) + if purl1.scheme != purl2.scheme: + return False + + if purl1.netloc != purl2.netloc: + return False + + if ignore_trailing_slash is True: + normfunc = append_trailing_slash + else: + normfunc = lambda v: v + + if normfunc(purl1.path) != normfunc(purl2.path): + return False + + #test remaining items in the parsed url + return purl1[3:] == purl2[3:] + def get_login_url(): """returns internal login url if django_authopenid is used, or |