Repository: MasoniteFramework/core

Issue:
Redirect does not compile url correctly
a redirect url of '/url/here'

compiles into "urlhere" for some reason. check tests because I thought this was fixed

Discussion:

Patch:
diff --git a/masonite/drivers/UploadDiskDriver.py b/masonite/drivers/UploadDiskDriver.py
index 410f732..e3721bc 100644
--- a/masonite/drivers/UploadDiskDriver.py
+++ b/masonite/drivers/UploadDiskDriver.py
@@ -12,6 +12,8 @@ class UploadDiskDriver(object):
         if not location:
             location = self.config.DRIVERS['disk']['location']
         
+        location += '/'
+        
         open(location + filename, 'wb').write(fileitem.file.read())
 
         return location + filename
diff --git a/masonite/request.py b/masonite/request.py
index 8036a6f..7586018 100644
--- a/masonite/request.py
+++ b/masonite/request.py
@@ -196,11 +196,18 @@ class Request(object):
             # if the url contains a parameter variable like @id:int
             if '@' in url:
                 url = url.replace('@', '').replace(':int', '').replace(':string', '')
-                print('url after @', url)
-                compiled_url += '/' + str(self.param(url)) + '/' 
+                compiled_url +=  str(self.param(url)) + '/' 
             else:
-                compiled_url += url
-        print('compiled_url:', compiled_url)
+                compiled_url += url + '/'
+
+        # The loop isn't perfect and may have an unwanted trailing slash
+        if compiled_url.endswith('/') and not self.redirect_url.endswith('/'):
+            compiled_url = compiled_url[:-1]
+        
+        # The loop isn't perfect and may have 2 slashes next to eachother
+        if '//' in compiled_url:
+            compiled_url = compiled_url.replace('//', '/')
+
         return compiled_url
     
     def has_subdomain(self):
diff --git a/setup.py b/setup.py
index 8e9a335..668e018 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ setup(
               'masonite.testsuite',
               'masonite.queues',
              ],
-    version='1.3.1',
+    version='1.3.2',
     install_requires=[
         'validator.py==1.2.5',
         'cryptography==2.1.4',


Test patch:
diff --git a/tests/test_requests.py b/tests/test_requests.py
index d68c2d8..f9b640f 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -149,3 +149,58 @@ def test_request_has_subdomain_returns_bool():
     request.environ['HTTP_HOST'] = 'test.localhost.com'
 
     assert request.has_subdomain() is True
+
+def test_redirect_compiles_url():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('test/url')
+
+    assert request.compile_route_to_url() == '/test/url'
+
+def test_redirect_compiles_url_with_multiple_slashes():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('test/url/here')
+
+    assert request.compile_route_to_url() == '/test/url/here'
+
+def test_redirect_compiles_url_with_trailing_slash():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('test/url/here/')
+
+    assert request.compile_route_to_url() == '/test/url/here/'
+
+def test_redirect_compiles_url_with_parameters():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('test/@id').send({'id': '1'})
+
+    assert request.compile_route_to_url() == '/test/1'
+
+def test_redirect_compiles_url_with_multiple_parameters():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('test/@id/@test').send({'id': '1', 'test': 'user'})
+
+    assert request.compile_route_to_url() == '/test/1/user'
+
+def test_redirect_compiles_url_with_http():
+    app = App()
+    app.bind('Request', REQUEST)
+    request = app.make('Request').load_app(app)
+
+    request.redirect('http://google.com')
+
+    assert request.compile_route_to_url() == 'http://google.com'
+