mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 08:16:07 +00:00
fix encode (#2462)
This commit is contained in:
@@ -587,7 +587,8 @@ def repo_revert_history(request, repo_id):
|
||||
def fpath_to_link(repo_id, path, is_dir=False):
|
||||
"""Translate file path of a repo to its view link"""
|
||||
if is_dir:
|
||||
href = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': path.encode('utf-8').strip('/')}
|
||||
href = HASH_URLS["VIEW_COMMON_LIB_DIR"] % {'repo_id': repo_id, 'path': path.strip('/')}
|
||||
href = urlquote(href, safe='/#')
|
||||
else:
|
||||
if not path.startswith('/'):
|
||||
p = '/' + path
|
||||
|
@@ -1,10 +1,14 @@
|
||||
# encoding: utf-8
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub.views import fpath_to_link
|
||||
from django.utils.http import urlquote
|
||||
|
||||
|
||||
class FpathToLinkTest(BaseTestCase):
|
||||
def test_fpath_to_link(self):
|
||||
path = '/'
|
||||
path = '/海文/'.decode('utf-8')
|
||||
resp = fpath_to_link(self.repo.id, path, is_dir=True)
|
||||
assert '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': path.encode('utf-8').strip('/')} in resp
|
||||
url = '/#common/lib/%(repo_id)s/%(path)s' % {'repo_id': self.repo.id,
|
||||
'path': path.strip('/')}
|
||||
|
||||
assert urlquote(url, safe='/#') in resp
|
||||
|
Reference in New Issue
Block a user