Allow relative localhost URIs

This commit is contained in:
Arnaud Renevier 2008-12-20 00:24:35 +01:00 committed by Christian Dywan
parent b88ba4094f
commit 993fb52644
2 changed files with 2 additions and 1 deletions

View file

@ -121,7 +121,7 @@ sokoke_magic_uri (const gchar* uri,
if (search && search[0] && !g_ascii_isalpha (search[1])) if (search && search[0] && !g_ascii_isalpha (search[1]))
if (!strchr (search, '.')) if (!strchr (search, '.'))
return g_strconcat ("http://", uri, NULL); return g_strconcat ("http://", uri, NULL);
if (!strcmp (uri, "localhost")) if (!strcmp (uri, "localhost") || g_str_has_prefix (uri, "localhost/"))
return g_strconcat ("http://", uri, NULL); return g_strconcat ("http://", uri, NULL);
parts = g_strsplit (uri, ".", 0); parts = g_strsplit (uri, ".", 0);
if (!search && parts[0] && parts[1]) if (!search && parts[0] && parts[1])

View file

@ -60,6 +60,7 @@ main (int argc,
g_free (b); g_free (b);
test_input ("localhost", "http://localhost"); test_input ("localhost", "http://localhost");
test_input ("localhost:8000", "http://localhost:8000"); test_input ("localhost:8000", "http://localhost:8000");
test_input ("localhost/rss", "http://localhost/rss");
test_input ("192.168.1.1", "http://192.168.1.1"); test_input ("192.168.1.1", "http://192.168.1.1");
test_input ("192.168.1.1:8000", "http://192.168.1.1:8000"); test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
test_input ("sm midori", SM "midori"); test_input ("sm midori", SM "midori");