Skip to content

Commit fddf599

Browse files
committed
Merge pull request #53 from scrapy/urljoin-import
Fix (deprecated) urljoin_rfc
2 parents 29c405c + b5e57a2 commit fddf599

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/test_url.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import unittest
55
from w3lib.url import (safe_url_string, safe_download_url,
66
url_query_parameter, add_or_replace_parameter, url_query_cleaner,
7-
file_uri_to_path, path_to_file_uri, any_to_uri)
7+
file_uri_to_path, path_to_file_uri, any_to_uri, urljoin_rfc)
88

99
class UrlTests(unittest.TestCase):
1010

@@ -315,6 +315,10 @@ def test_any_to_uri(self):
315315
self.assertEqual(any_to_uri("http://www.example.com/some/path.txt"),
316316
"http://www.example.com/some/path.txt")
317317

318+
def test_urljoin_rfc_deprecated(self):
319+
jurl = urljoin_rfc("http://www.example.com/", "/test")
320+
self.assertEqual(jurl, b"http://www.example.com/test")
321+
318322

319323
if __name__ == "__main__":
320324
unittest.main()

w3lib/url.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def urljoin_rfc(base, ref, encoding='utf-8'):
5757
warnings.warn("w3lib.url.urljoin_rfc is deprecated, use urlparse.urljoin instead",
5858
DeprecationWarning)
5959

60-
str_base = unicode_to_str(base, encoding)
61-
str_ref = unicode_to_str(ref, encoding)
60+
str_base = to_bytes(base, encoding)
61+
str_ref = to_bytes(ref, encoding)
6262
return urljoin(str_base, str_ref)
6363

6464
_reserved = b';/?:@&=+$|,#' # RFC 3986 (Generic Syntax)

0 commit comments

Comments
 (0)