Fix is_special_url (use QUrl).

This commit is contained in:
Florian Bruhin 2014-06-20 20:21:52 +02:00
parent 7de637baea
commit 9a33efdb3f
2 changed files with 12 additions and 4 deletions

View File

@ -24,6 +24,8 @@
import unittest
from unittest import TestCase
from PyQt5.QtCore import QUrl
import qutebrowser.utils.url as urlutils
@ -85,12 +87,14 @@ class SpecialURLTests(TestCase):
def test_special_urls(self):
"""Test special URLs."""
for url in self.SPECIAL_URLS:
self.assertTrue(urlutils.is_special_url(url))
u = QUrl(url)
self.assertTrue(urlutils.is_special_url(u))
def test_normal_urls(self):
"""Test non-special URLs."""
for url in self.NORMAL_URLS:
self.assertFalse(urlutils.is_special_url(url))
u = QUrl(url)
self.assertFalse(urlutils.is_special_url(u))
class SearchUrlTests(TestCase):

View File

@ -131,9 +131,13 @@ def fuzzy_url(urlstr):
def is_special_url(url):
"""Return True if url is an about:... or other special URL."""
"""Return True if url is an about:... or other special URL.
Args:
url: The URL as QUrl.
"""
special_schemes = ('about', 'qute', 'file')
return QUrl(url).scheme() in special_schemes
return url.scheme() in special_schemes
def is_url(urlstr):