﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30895	Multiples trailing slashes appended to URL	Conor Cunningham	nobody	"I'm not sure whether this is a feature or a bug, but failing in my attempt to get an answer in #django or django-users, I thought it best to report it.

=== Summary
In short I have a URL which will be either ```/api/v1/case/``` if ```APPEND_SLASH=True,``` or ```/api/v1 case``` if ```APPEND_SLASH = False```.
The URL ```/api/v1/case/``` is made up of two URLS, namely ```/api/v1``` and ```/case```, one from the projects ```urls.py``` and the other from the app's ```urls.py```. What I suspect is happening is that a trailing slash is being appended to both the URLS before they are concatenated to make the final URL.

**Django Version**: 2.2.6
**Installed Apps**: 
django-allauth==0.40.0
django-cors-headers==3.1.1
django-crispy-forms==1.7.2
django-environ==0.4.5
django-rest-auth==0.9.5
django-rest-swagger==2.2.0
djangorestframework==3.10.3
djangorestframework-simplejwt==4.3.0


=== Reproduction
It should be first mentioned that I am using DRF to provide API functionality for my views mentioned herein, and that I am using Docker both locally for development, and on the production server. The issue is reproducible in both environments.

I should also note that I can avoid this behaviour by configuring the URLs in a different (what I presume to be the correct way)

To reproduce this, I have a project ```urls.py``` file with the following

```path('api/v1', include('api.urls')),``` - (note there is no trailing slash)

And an app called **api** with a URL file, ```api/urls.py``` with the following

```path('case', CasesView.as_view(), name='all-cases'),```

If you have a URL configured as above and ```APPEND_SLASH=True``` you will be able to navigate to the URL ```/api/v1/case/```. If ```APPEND_SLASH=False```, then navigating to the aforementioned URL, you will receive a 404 and Django debug will report that it tried a URL of ```/api/v1 case```

In addition to what appears to be two slashes being rendered into the final URL, I am also curious as to where the blank space in the URL ```/api/v1 case``` comes from, as there is no whitespace in either of the two configured URLs.

I can avoid this behaviour entirely, regardless of what ```APPEND_SLASH``` is set, by configuring the project URl as:
```path('api/v1/', include('api.urls')),```

and the app URL as:

```path('case', CasesView.as_view(), name='all-cases'),```

The difference only being in that I have hardcoded a trailing slash into the project URL's path.

=== Final Thoughts

The reason I think this is a bug, is that the behaviour, at least to me is non-obvious. That's not to say when you stop and think about it that it isn't perhaps logical, if indeed there are two URLs which have slashes appended to them in order to make the final URL, but on first glance when I read about Django's APPEND_SLASH feature, I think of the final URL, the one that the user will see, not of two separate URLs  that are being put together to make the final product.

However, the thing that makes me think that perhaps this isn't a bug, is that I seemingly just didn't configure Django properly. It could be as simple as that, and I apologise if that is the case.

I am only too happy to provide any further information that may be of use in investigating this issue, if indeed it turns out to be an issue.

Cheers,

Conor"	Bug	closed	Core (URLs)	2.2	Normal	invalid	urls, url	Conor Cunningham	Unreviewed	0	0	0	0	0	0
