Sorry if this question seems a little redundant, but this is what really bothers me.
I have an API set written in Django defined by the following URLs.
import ...
urlpatterns = [
url(r"^api/v1/account", include(profile.urls))
]
and
import ...
urlpatterns = [
url(r"^$", AccountAPI.as_view()),
url(r"^/login$", LoginAPI.as_view()),
url(r"^/logout$", LogoutAPI.as_view())
]
This configuration should only allow URLs:
/api/v1/account
/api/v1/account/login
/api/v1/account/logout
This work is for my purpose, but I have such warnings (I have several APIs defined with this rule, and the list of warnings is longer):
?: (urls.W002) Your URL pattern '^/login$' has a regex beginning with a '/'. Remove this slash as it is unnecessary.
?: (urls.W002) Your URL pattern '^/logout$' has a regex beginning with a '/'. Remove this slash as it is unnecessary.
If I delete the slash , the server will not check the URLs I have defined. To do this, I must have a slash to the first level of URLs, for example:
import ...
urlpatterns = [
url(r"^api/v1/account/", include(profile.urls))
]
And this will cause the account invocation to end with a slash, which I don't want.
, URL- , , , , .
- ? URL- , ? ?