Repository navigation
Commit e066515
committed
fix(routes): mint Laravel routes written without a leading slash
Why: Laravel accepts a route URI with or without its leading slash and trims
'/' from both ends, so Route::get('users', ...) serves /users and
Route::get('', ...) the group root. Most Laravel apps write it that way. Both
route passes only minted a Route for a first argument starting with '/', so
Firefly III's API registrations (246 distinct routes in routes/api.php) had
no Route at all, and neither did laravel.io's PUT/DELETE API routes or 62 of
its 67 registrations.
Fix (extract_calls.c, PHP only; other languages' path gates are untouched):
- A recognised Laravel registration gets its literal URI normalised to the
slashed form before the gates: 'users' -> /users, '' -> /, 'users/' ->
/users. It is recognised by an HTTP verb (get/post/put/patch/delete)
called on the Route facade - directly, or at the root of a registrar chain
such as Route::middleware('auth')->get(...) - or on $router. The literal
`Route` scope is the same one the DeusData#952 callee qualification accepts. Any
other call keeps its argument: $request->get('name'), Cache::get('key'),
config(), a collection's or session's get(), $this->router->get(), and a
test client's $this->get('users').
- The normalised path composes with the enclosing in-file prefix groups the
same way as DeusData#952. The attribute-array group form
Route::group(['prefix' => 'v1/autocomplete', ...], function () {...}),
which Firefly III's whole API uses, now contributes its prefix too;
without it those routes would mint as /accounts instead of
/v1/autocomplete/accounts.
- A slashless registration whose action is a string ('index' inside a
Route::controller() group, 'UserController@store') is minted without a
handler. The string does not say which class owns the method, and
resolving it could only guess: on krayin/laravel-crm, 'update' and
'destroy' bound functions in a bundled chart.js, and 'store' bound
ActivityController for /login.
Proof (release CLI built from this tree vs origin/main 1f9b4db):
- Routes minted by route registration: firefly-iii 30 -> 651,
laravel.io 39 -> 81, krayin/laravel-crm 5 -> 132. An independent
recomputation of every composed path from the route files matches
exactly: firefly routes/api.php 246/246 and routes/web.php 390/390,
laravel.io web 64/64 and api 3/3, with 0 missing and 0 extra.
- Samples checked against source: GET /v1/autocomplete/accounts and
DELETE /v1/accounts/{account} (firefly), PUT /articles/{article} (laravel.io
api), PUT /admin/articles/{article}/approve (laravel.io web), and
PUT /leads/edit/{id} (krayin).
- No false Routes: every new route-registration edge comes from a Route::
registrar in a route file. The pre-existing test-client and JS-client
route edges are identical to main. HANDLES stays at 0 on all three
corpora, so no handler is guessed.
Tests (edge_types_probe): routes_laravel_slashless_issue1146 and
routes_laravel_slashless_parallel_issue1146 assert the exact method+path set:
facade, facade chain, $router, chain and array prefix groups, '' and a
trailing slash. routes_laravel_slashless_no_junk_issue1146 covers the
non-route string calls. routes_laravel_slashless_no_guessed_handlers_issue1146
checks string actions against JS and PHP decoys. RED on origin/main 3x,
green, RED on revert (the guessed-handler test is also RED with only the
handler gate removed). edge_types_probe, php_lsp, pipeline, parallel,
route_canon and cross_repo pass (731); make lint-ci passes.
Refs DeusData#1146
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent b05a68c commit e066515
2 files changed
Lines changed: 309 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1763 | 1763 | | |
1764 | 1764 | | |
1765 | 1765 | | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
1766 | 1819 | | |
1767 | 1820 | | |
1768 | 1821 | | |
| |||
1785 | 1838 | | |
1786 | 1839 | | |
1787 | 1840 | | |
1788 | | - | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
1789 | 1849 | | |
1790 | 1850 | | |
1791 | 1851 | | |
| |||
1843 | 1903 | | |
1844 | 1904 | | |
1845 | 1905 | | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
1846 | 1981 | | |
1847 | 1982 | | |
1848 | 1983 | | |
| |||
3941 | 4076 | | |
3942 | 4077 | | |
3943 | 4078 | | |
| 4079 | + | |
| 4080 | + | |
| 4081 | + | |
| 4082 | + | |
| 4083 | + | |
| 4084 | + | |
| 4085 | + | |
| 4086 | + | |
| 4087 | + | |
| 4088 | + | |
3944 | 4089 | | |
3945 | 4090 | | |
3946 | 4091 | | |
| |||
3959 | 4104 | | |
3960 | 4105 | | |
3961 | 4106 | | |
3962 | | - | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
3963 | 4111 | | |
3964 | 4112 | | |
3965 | 4113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
925 | 1080 | | |
926 | 1081 | | |
927 | 1082 | | |
| |||
2138 | 2293 | | |
2139 | 2294 | | |
2140 | 2295 | | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
2141 | 2300 | | |
2142 | 2301 | | |
2143 | 2302 | | |
| |||
0 commit comments