Merge pull request #389 from taigaio/bug/2402/export-url-must-be-absolute

Bug#2402 Add resolveAbsolute method and used in csv export url building
stable
Alejandro 2015-03-12 08:43:08 +01:00
commit a616ef3c80
2 changed files with 9 additions and 1 deletions

View File

@ -640,7 +640,7 @@ class CsvExporterController extends taiga.Controller
@rootscope.$on("project:loaded", @.setCsvUuid)
@scope.$watch "csvUuid", (value) =>
if value
@scope.csvUrl = @urls.resolve("#{@.type}-csv", value)
@scope.csvUrl = @urls.resolveAbsolute("#{@.type}-csv", value)
else
@scope.csvUrl = ""

View File

@ -49,6 +49,14 @@ class UrlsService extends taiga.Service
_.str.ltrim(url, "/")
])
resolveAbsolute: ->
url = @.resolve.apply(@, arguments)
if (/^https?:\/\//i).test(url)
return url
if (/^\//).test(url)
return "#{window.location.protocol}//#{window.location.host}#{url}"
return "#{window.location.protocol}//#{window.location.host}/#{url}"
module = angular.module("taigaBase")
module.service('$tgUrls', UrlsService)