Body: <p>Craft hasn't done this prior (or maybe I just noticed), but I'm currently battling double slashes in URLs returned from <code>{{ asset.getUrl() }}</code>.</p>
  
  <p>The issue appears when I create an Assets field and set the following settings to that field:</p>
  
  <p><em>Restrict uploads to a single folder (true)</em><br>
  <em>Upload location: [source:Images] <code>somefolder/somesubfolder</code></em></p>
  
  <p>Calling <code>{{ asset.getUrl() }}</code> on an asset from this field returns the following URL:</p>
  
  <p><strong><code>/uploads/images/somefolder//somesubfolder/image.jpg</code></strong></p>
  
  <p>Notice that the double slash appears inside the path specified in the field's settings – <code>/uploads/images/</code> is the source path.</p>
  
  <p>This happens both for Asset fields that are inside Matrix fields, and standalone fields. It also happens regardless if I use named transforms, inline transforms or no transforms (<code>getUrl(false)</code>).</p>
  
  <p><em>If the source configuration should prove relevant somehow, here's the setup:</em></p>
  
  <p>I've got an asset source (local folder) called <code>Images</code> configured like this:  </p>
  
  <p><em>File System Path:</em> <code>{imagePath}/</code><br>
  <em>URL:</em> <code>{imageUri}/</code></p>
  
  <p><code>{imagePath}</code> and <code>{imageUri}</code> are environment variables, set to <code>$_SERVER['DOCUMENT_ROOT'] . "/uploads/images"</code> and <code>"/uploads/images"</code>, respectively.</p>
  
  <p>Not sure if this is a bug or something I do wrong somehow (or maybe it has to do with server configurations?). I can remove the double slashes with Twig, but it's annoying. Why does this happen, and is there anything I can do about it?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-15T21:07:02.900Z
Comments.Text: I just setup a test locally exactly as you described and I'm not getting a double `//` path separator. `/Users/Brad/Dropbox/Sites/craft.dev/public/uploads/somefolder/somesubfolder/PT7-2.jpg`
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-15T21:09:45.593Z
Comments.Text: @BradBell Thanks – it's a weird one. Probably something in my setup somehow. I'll do some debugging and will report back if I find the cause.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-26T04:55:48.080Z
Comments.Text: We are getting the same problem in Craft 2.4.2693. It's causing issues with Facebook Open Graph.
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-26T05:07:06.700Z
Comments.Text: In our case, it was caused by a bad environment in general.php
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-26T21:52:43.510Z
Comments.Text: @Ryan – I never actually solved this. Can you elaborate? What do you mean by "bad environment"?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-01T09:20:05.357Z
Comments.Text: There is an `environmentVariables` array in `general.php`. We were actually generating double-slashes unintentionally. Something like "'assetsImagesUrl'  => SITE_URL.'/uploads/images'", where SITE_URL already had a slash on the end. I only commented to save others from the same mistake - I don't think it's your issue.
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-01T10:36:14.323Z
Comments.Text: Yeah, that wasn't my issue, but it's definitely something that can easily happen. Thanks for clearing it up @Ryan!
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Tags: <templating><assets><content>
Title: asset.getUrl() outputs double slashes
ThreadText: # asset.getUrl() outputs double slashes
  
  (Asked by: username_0 on 2015-10-15)
  
  Craft hasn't done this prior (or maybe I just noticed), but I'm currently battling double slashes in URLs returned from `{{ asset.getUrl() }}`.
  
  The issue appears when I create an Assets field and set the following settings to that field:
  
  *Restrict uploads to a single folder (true)*  
  *Upload location: [source:Images] `somefolder/somesubfolder`*
  
  Calling `{{ asset.getUrl() }}` on an asset from this field returns the following URL:
  
  **`/uploads/images/somefolder//somesubfolder/image.jpg`**
  
  Notice that the double slash appears inside the path specified in the field's settings – `/uploads/images/` is the source path.
  
  This happens both for Asset fields that are inside Matrix fields, and standalone fields. It also happens regardless if I use named transforms, inline transforms or no transforms (`getUrl(false)`).
  
  *If the source configuration should prove relevant somehow, here's the setup:*
  
  I've got an asset source (local folder) called `Images` configured like this:
  
  *File System Path:* `{imagePath}/`  
  *URL:* `{imageUri}/`
  
  `{imagePath}` and `{imageUri}` are environment variables, set to `$_SERVER['DOCUMENT_ROOT'] . "/uploads/images"` and `"/uploads/images"`, respectively.
  
  Not sure if this is a bug or something I do wrong somehow (or maybe it has to do with server configurations?). I can remove the double slashes with Twig, but it's annoying. Why does this happen, and is there anything I can do about it?
  
  **Tags:** templating, assets, content
  
  > **Comments:**
  > **username_1**: I just setup a test locally exactly as you described and I'm not getting a double `//` path separator. `/Users/username_1/Dropbox/Sites/craft.dev/public/uploads/somefolder/somesubfolder/PT7-2.jpg`  
  > **username_0**: @username_1 Thanks – it's a weird one. Probably something in my setup somehow. I'll do some debugging and will report back if I find the cause.  
  > **username_2**: We are getting the same problem in Craft 2.4.2693. It's causing issues with Facebook Open Graph.  
  > **username_2**: In our case, it was caused by a bad environment in general.php  
  > **username_0**: @username_2 – I never actually solved this. Can you elaborate? What do you mean by "bad environment"?  
  > **username_2**: There is an `environmentVariables` array in `general.php`. We were actually generating double-slashes unintentionally. Something like "'assetsImagesUrl'  => SITE_URL.'/uploads/images'", where SITE_URL already had a slash on the end. I only commented to save others from the same mistake - I don't think it's your issue.  
  > **username_0**: Yeah, that wasn't my issue, but it's definitely something that can easily happen. Thanks for clearing it up @username_2!  
  
  ---
  
  ## 0 answers
  
  