Check if a slash-prefixed string looks like a REST API path.
| 1356 | |
| 1357 | // Check if a slash-prefixed string looks like a REST API path. |
| 1358 | static bool is_rest_path(const char *s, int len) { |
| 1359 | if (is_filesystem_path(s, len)) { |
| 1360 | return false; |
| 1361 | } |
| 1362 | if (len > SKIP_ONE && s[len - SKIP_ONE] == '/') { |
| 1363 | return false; /* regex pattern */ |
| 1364 | } |
| 1365 | if (s[SKIP_ONE] == '^') { |
| 1366 | return false; /* regex */ |
| 1367 | } |
| 1368 | if (len == SKIP_ONE || (len == PAIR_LEN && s[SKIP_ONE] == '/')) { |
| 1369 | return false; /* bare / or // */ |
| 1370 | } |
| 1371 | if (s[SKIP_ONE] == '.') { |
| 1372 | return false; /* relative path */ |
| 1373 | } |
| 1374 | for (int i = SKIP_ONE; i < len && i < MAX_ROUTE_SCAN; i++) { |
| 1375 | char c = s[i]; |
| 1376 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) { |
| 1377 | return true; |
| 1378 | } |
| 1379 | } |
| 1380 | return false; |
| 1381 | } |
| 1382 | |
| 1383 | static bool is_url_like(const char *s, int len) { |
| 1384 | if (len < MIN_ROUTE_LEN) { |
no test coverage detected