File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -649,6 +649,9 @@ namespace crow
649
649
650
650
void validate () override
651
651
{
652
+ if (rule_.at (0 ) != ' /' )
653
+ throw std::runtime_error (" Internal error: Routes must start with a '/'" );
654
+
652
655
if (!handler_)
653
656
{
654
657
throw std::runtime_error (name_ + (!name_.empty () ? " : " : " " ) + " no handler for url " + rule_);
Original file line number Diff line number Diff line change 4
4
#include < sys/stat.h>
5
5
6
6
#include < iostream>
7
- #include < sstream>
8
7
#include < vector>
9
8
#include < thread>
10
9
#include < chrono>
@@ -149,6 +148,27 @@ TEST_CASE("PathRouting")
149
148
}
150
149
} // PathRouting
151
150
151
+ TEST_CASE (" InvalidPathRouting" )
152
+ {
153
+ SimpleApp app;
154
+
155
+ CROW_ROUTE (app, " invalid_route" )
156
+ ([] {
157
+ return " should not arrive here" ;
158
+ });
159
+
160
+ try
161
+ {
162
+ app.validate ();
163
+ FAIL_CHECK ();
164
+ }
165
+ catch (std::exception& e)
166
+ {
167
+ auto expected_exception_text = " Internal error: Routes must start with a '/'" ;
168
+ CHECK (strcmp (expected_exception_text, e.what ()) == 0 );
169
+ }
170
+ } // InvalidPathRouting
171
+
152
172
TEST_CASE (" RoutingTest" )
153
173
{
154
174
SimpleApp app;
You can’t perform that action at this time.
0 commit comments