Skip to content

Commit e4f88dc

Browse files
committed
Allow uppercase in URLs
1 parent 5534249 commit e4f88dc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/url.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Url
8484

8585
void match(const std::string& str)
8686
{
87-
static const std::regex regex("(([a-z]+)://)((\\[[:a-z-A-Z0-9]+\\])|([a-z0-9-.]*))(:([0-9]+))?(/.*)?$");
87+
static const std::regex regex("(([a-z]+)://)((\\[[:a-zA-Z0-9]+\\])|([a-zA-Z0-9-.]*))(:([0-9]+))?(/.*)?$");
8888
std::smatch match;
8989

9090
_valid = false;

tests/test.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,14 @@ TEST(url)
24872487
url.setPort(631);
24882488
ASSERT(url.toStr() == "ipp://myprinter:631/ipp/print");
24892489

2490+
url = "ipp://MyPrinter/ipp/FOO";
2491+
ASSERT(url.isValid());
2492+
ASSERT(url.getScheme() == "ipp");
2493+
ASSERT(url.getHost() == "MyPrinter");
2494+
ASSERT(url.getPort() == 0);
2495+
ASSERT(url.getPath() == "/ipp/FOO");
2496+
ASSERT(url.toStr() == "ipp://MyPrinter/ipp/FOO");
2497+
24902498
url = "ipp://myprinter";
24912499
ASSERT(url.isValid());
24922500
ASSERT(url.getScheme() == "ipp");
@@ -2532,4 +2540,21 @@ TEST(url)
25322540
ASSERT(url.getPort() == 631);
25332541
ASSERT(url.getPath() == "/ipp/print");
25342542
ASSERT(url.toStr() == "ipp://[::1]:631/ipp/print");
2543+
2544+
url = "ipp://[2001:db8:3c4d:15::1a2f:1a2b]:631/ipp/print";
2545+
ASSERT(url.isValid());
2546+
ASSERT(url.getScheme() == "ipp");
2547+
ASSERT(url.getHost() == "[2001:db8:3c4d:15::1a2f:1a2b]");
2548+
ASSERT(url.getPort() == 631);
2549+
ASSERT(url.getPath() == "/ipp/print");
2550+
ASSERT(url.toStr() == "ipp://[2001:db8:3c4d:15::1a2f:1a2b]:631/ipp/print");
2551+
2552+
url = "ipp://[:BEEF]:631/ipp/print";
2553+
ASSERT(url.isValid());
2554+
ASSERT(url.getScheme() == "ipp");
2555+
ASSERT(url.getHost() == "[:BEEF]");
2556+
ASSERT(url.getPort() == 631);
2557+
ASSERT(url.getPath() == "/ipp/print");
2558+
ASSERT(url.toStr() == "ipp://[:BEEF]:631/ipp/print");
2559+
25352560
}

0 commit comments

Comments
 (0)