Skip to content

Commit 8556476

Browse files
bbaylesanonrig
authored andcommitted
Example for replace_url
1 parent 81d7dd7 commit 8556476

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: README.rst

+2
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ It also provides some higher level functions for parsing and manipulating URLs.
4545
'search': '?q=1',
4646
'hash': '#2'
4747
}
48+
>>> ada_url.replace_url('http://example.org:80', protocol='https:')
49+
'https://example.org/'

Diff for: ada_url/ada_adapter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def replace_url(s, **kwargs):
304304

305305
for attr in URL_ATTRIBUTES:
306306
value = kwargs.get(attr)
307-
if not value:
307+
if value is None:
308308
continue
309309

310310
try:

Diff for: tests/test_ada_url.py

+6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ def test_replace_url(self):
242242
actual = replace_url(s, **kwargs)
243243
self.assertEqual(actual, expected)
244244

245+
def test_replace_blank(self):
246+
s = 'https://user:[email protected]'
247+
actual = replace_url(s, username='', password='')
248+
expected = 'https://example.org/'
249+
self.assertEqual(actual, expected)
250+
245251
def test_replace_href(self):
246252
s = 'https://username:[email protected]:8080/'
247253
kwargs = {

0 commit comments

Comments
 (0)