Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Microsoft.Plugin.Uri.UnitTests/UriHelper/ExtendedUriParserTests.cs (C#)

Code before:
        [DataRow("google.com:91/126", true, "https://google.com:91/126", null)]
        [DataRow("test.test.test.test:952", true, "https://test.test.test.test:952/", null)]
        [DataRow("test.test.test.test:952/test", true, "https://test.test.test.test:952/test", null)]
        [DataRow("test.test.test.test:952/126", true, "https://test.test.test.test:952/126", null)]

        // Following cases can be both interpreted as schema:path and domain:port
        [DataRow("tel:411", true, "https://tel:411/", "tel:411")]
        [DataRow("tel:70421567", true, null, "tel:70421567")]
        [DataRow("tel:863-1234", true, null, "tel:863-1234")]
        [DataRow("tel:tel:+1-201-555-0123", true, null, "tel:tel:+1-201-555-0123")]

        // All following cases should be parsed as application URI
        [DataRow("mailto:", true, null, "mailto:")]
        [DataRow("mailto:/", false, null, null)]
        [DataRow("ms-settings:", true, null, "ms-settings:")]
        [DataRow("ms-settings:/", false, null, null)]
        [DataRow("ms-settings://", false, null, null)]
        [DataRow("ms-settings://privacy", true, null, "ms-settings://privacy/")]
        [DataRow("ms-settings://privacy/", true, null, "ms-settings://privacy/")]
        [DataRow("ms-settings:privacy", true, null, "ms-settings:privacy")]
        [DataRow("ms-settings:powersleep", true, null, "ms-settings:powersleep")]
        [DataRow("microsoft-edge:http://google.com", true, null, "microsoft-edge:http://google.com")]
        [DataRow("microsoft-edge:https://google.com", true, null, "microsoft-edge:https://google.com")]
        [DataRow("microsoft-edge:google.com", true, null, "microsoft-edge:google.com")]
        [DataRow("microsoft-edge:google.com/", true, null, "microsoft-edge:google.com/")]
        [DataRow("microsoft-edge:https://google.com/", true, null, "microsoft-edge:https://google.com/")]
        [DataRow("ftp://user:password@localhost:8080", true, null, "ftp://user:password@localhost:8080/")]
        [DataRow("ftp://user:password@localhost:8080/", true, null, "ftp://user:password@localhost:8080/")]
        [DataRow("ftp://user:password@google.com", true, null, "ftp://user:password@google.com/")]
        [DataRow("ftp://user:password@google.com:2121", true, null, "ftp://user:password@google.com:2121/")]
        [DataRow("ftp://user:password@1.1.1.1", true, null, "ftp://user:password@1.1.1.1/")]
        [DataRow("ftp://user:password@1.1.1.1:2121", true, null, "ftp://user:password@1.1.1.1:2121/")]
        [DataRow("^:", false, null, null)]

        public void TryParseCanParseHostName(string query, bool expectedSuccess, string expectedWebUri, string expectedSystemUri)
        {
            // Arrange
            var parser = new ExtendedUriParser();

            // Act
            var success = parser.TryParse(query, out var webUriResult, out var systemUriResult);

            // Assert
            Assert.AreEqual(expectedWebUri, webUriResult?.ToString());
            Assert.AreEqual(expectedSystemUri, systemUriResult?.ToString());
            Assert.AreEqual(expectedSuccess, success);
        }
    }
}


Review comment (refactor):
Duplicated. But we should test the three cases (without proto, http and https) with port too to make sure it works.

Code after:
        [DataRow("test.test.test.test:952/test", true, "https://test.test.test.test:952/test", null)]
        [DataRow("test.test.test.test:952/126", true, "https://test.test.test.test:952/126", null)]

        // Following cases can be both interpreted as schema:path and domain:port
        [DataRow("tel:411", true, "https://tel:411/", "tel:411")]
        [DataRow("tel:70421567", true, null, "tel:70421567")]
        [DataRow("tel:863-1234", true, null, "tel:863-1234")]
        [DataRow("tel:+1-201-555-0123", true, null, "tel:+1-201-555-0123")]

        // All following cases should be parsed as application URI
        [DataRow("mailto:", true, null, "mailto:")]
        [DataRow("mailto:/", false, null, null)]
        [DataRow("mailto:example@mail.com", true, null, "mailto:example@mail.com")]
        [DataRow("ms-settings:", true, null, "ms-settings:")]
        [DataRow("ms-settings:/", false, null, null)]
        [DataRow("ms-settings://", false, null, null)]
        [DataRow("ms-settings://privacy", true, null, "ms-settings://privacy/")]
        [DataRow("ms-settings://privacy/", true, null, "ms-settings://privacy/")]
        [DataRow("ms-settings:privacy", true, null, "ms-settings:privacy")]
        [DataRow("ms-settings:powersleep", true, null, "ms-settings:powersleep")]
        [DataRow("microsoft-edge:google.com", true, null, "microsoft-edge:google.com")]
        [DataRow("microsoft-edge:google.com/", true, null, "microsoft-edge:google.com/")]
        [DataRow("microsoft-edge:google.com:80/", true, null, "microsoft-edge:google.com:80/")]
        [DataRow("microsoft-edge:google.com:443/", true, null, "microsoft-edge:google.com:443/")]
        [DataRow("microsoft-edge:google.com:1234/", true, null, "microsoft-edge:google.com:1234/")]
        [DataRow("microsoft-edge:http://google.com", true, null, "microsoft-edge:http://google.com")]
        [DataRow("microsoft-edge:http://google.com:80", true, null, "microsoft-edge:http://google.com:80")]
        [DataRow("microsoft-edge:http://google.com:443", true, null, "microsoft-edge:http://google.com:443")]
        [DataRow("microsoft-edge:http://google.com:1234", true, null, "microsoft-edge:http://google.com:1234")]
        [DataRow("microsoft-edge:https://google.com", true, null, "microsoft-edge:https://google.com")]
        [DataRow("microsoft-edge:https://google.com:80", true, null, "microsoft-edge:https://google.com:80")]
        [DataRow("microsoft-edge:https://google.com:443", true, null, "microsoft-edge:https://google.com:443")]
        [DataRow("microsoft-edge:https://google.com:1234", true, null, "microsoft-edge:https://google.com:1234")]
        [DataRow("ftp://user:password@localhost:8080", true, null, "ftp://user:password@localhost:8080/")]
        [DataRow("ftp://user:password@localhost:8080/", true, null, "ftp://user:password@localhost:8080/")]
        [DataRow("ftp://user:password@google.com", true, null, "ftp://user:password@google.com/")]
        [DataRow("ftp://user:password@google.com:2121", true, null, "ftp://user:password@google.com:2121/")]
        [DataRow("ftp://user:password@1.1.1.1", true, null, "ftp://user:password@1.1.1.1/")]
        [DataRow("ftp://user:password@1.1.1.1:2121", true, null, "ftp://user:password@1.1.1.1:2121/")]
        [DataRow("ftp://example.com", true, null, "ftp://example.com/")]
        [DataRow("ftp://example.com/test", true, null, "ftp://example.com/test")]
        [DataRow("ftp://example.com:123/test", true, null, "ftp://example.com:123/test")]
        [DataRow("ftp://example.com/126", true, null, "ftp://example.com/126")]
        [DataRow("^:", false, null, null)]

        public void ParserReturnsExpectedResults(string query, bool expectedSuccess, string expectedWebUri, string expectedSystemUri)
        {
            // Arrange
            var parser = new ExtendedUriParser();

            // Act