Auto-link column values that look like URLs

Refs #153
This commit is contained in:
Simon Willison 2017-11-29 09:05:24 -08:00
commit b67890d15d
No known key found for this signature in database
GPG key ID: FBB38AFE227189DB
3 changed files with 30 additions and 0 deletions

View file

@ -151,3 +151,13 @@ def test_detect_fts():
assert None is utils.detect_fts(conn, 'Dumb_Table')
assert None is utils.detect_fts(conn, 'Test_View')
assert 'Street_Tree_List_fts' == utils.detect_fts(conn, 'Street_Tree_List')
@pytest.mark.parametrize('url,expected', [
('http://www.google.com/', True),
('https://example.com/', True),
('www.google.com', False),
('http://www.google.com/ is a search engine', False),
])
def test_is_url(url, expected):
assert expected == utils.is_url(url)