diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 48b9e4af16..be09a2964c 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -525,8 +525,7 @@ class MirrorUriTest(FetcherTest):
 
     mirrorvar = "http://.*/.* file:///somepath/downloads/ " \
                 "git://someserver.org/bitbake git://git.openembedded.org/bitbake " \
-                "https://.*/.* file:///someotherpath/downloads/ " \
-                "http://.*/.* file:///someotherpath/downloads/ " \
+                "https?://.*/.* file:///someotherpath/downloads/ " \
                 "svn://svn.server1.com/ svn://svn.server2.com/"
 
     def test_urireplace(self):
@@ -1415,12 +1414,17 @@ class URLHandle(unittest.TestCase):
        "https://somesite.com/somerepo.git;user=anyUser:idtoken=1234" : ('https', 'somesite.com', '/somerepo.git', '', '', {'user': 'anyUser:idtoken=1234'}),
        'git://s.o-me_ONE:%s@git.openembedded.org/bitbake;branch=main;protocol=https' % password: ('git', 'git.openembedded.org', '/bitbake', 's.o-me_ONE', password, {'branch': 'main', 'protocol' : 'https'}),
     }
-    # we require a pathname to encodeurl but users can still pass such urls to 
-    # decodeurl and we need to handle them
+    # We require a pathname to encodeurl but users can still pass URLs without
+    # a path to decodeurl and we need to handle them. decodeurl is also used to
+    # split the regular expression "URLs" that are used in PREMIRRORS and
+    # MIRRORS.
     decodedata = datatable.copy()
     decodedata.update({
        "http://somesite.net;someparam=1": ('http', 'somesite.net', '/', '', '', {'someparam': '1'}),
        "npmsw://some.registry.url;package=@pkg;version=latest": ('npmsw', 'some.registry.url', '/', '', '', {'package': '@pkg', 'version': 'latest'}),
+       r"git://.*/.*": ("git", ".*", "/.*", "", "", {}),
+       r"https?://.*/.*": ("https?", ".*", "/.*", "", "", {}),
+       r"git://(?!internal\.git\.server).*/.*": ("git", r"(?!internal\.git\.server).*", "/.*", "", "", {}),
     })
 
     def test_decodeurl(self):
