From dd29b0692cf10d29692e474f805a1ae3c31188e1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 2 Aug 2017 08:11:03 +0200 Subject: [PATCH] Improved url error handling. --- app/assets/javascripts/app/controllers/import_zendesk.coffee | 2 +- app/controllers/import_zendesk_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/import_zendesk.coffee b/app/assets/javascripts/app/controllers/import_zendesk.coffee index b076c7210..ee12e9177 100644 --- a/app/assets/javascripts/app/controllers/import_zendesk.coffee +++ b/app/assets/javascripts/app/controllers/import_zendesk.coffee @@ -117,7 +117,7 @@ class Index extends App.ControllerContent e.preventDefault() @urlStatus.attr('data-state', '') url = @zendeskUrl.val() + '/agent/admin/api' - @zendeskUrlApiToken.attr('href', url.replace('//', '/')) + @zendeskUrlApiToken.attr('href', url.replace(/[^:]\/\//, '/')) @zendeskUrlApiToken.val('HERE') @$('[data-slide=zendesk-url]').toggleClass('hide') @$('[data-slide=zendesk-credentials]').toggleClass('hide') diff --git a/app/controllers/import_zendesk_controller.rb b/app/controllers/import_zendesk_controller.rb index b77056e3a..f762c2321 100644 --- a/app/controllers/import_zendesk_controller.rb +++ b/app/controllers/import_zendesk_controller.rb @@ -50,7 +50,7 @@ class ImportZendeskController < ApplicationController end endpoint = "#{params[:url]}/api/v2" - endpoint.gsub('//', '/') + endpoint.gsub(%r{[^:]//}, '/') Setting.set('import_zendesk_endpoint', endpoint) render json: {