package com.chbi.rest;

import com.chbi.ApplicationConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * Handles the jenkins urls, appends the json api suffix and replaces url parts if necessary.
 */
@Service
public class UrlRewriter {

    public static final String API_JSON_URL_ENDING = "api/json";

    @Autowired
    private ApplicationConfiguration configuration;

    String prepareUrl(String baseUrl) {

        String preparedUrl = StringUtils.replace(baseUrl, configuration.getUrlSearchPattern(),
                configuration.getUrlReplacement());
        preparedUrl += API_JSON_URL_ENDING;

        return preparedUrl;
    }

    String getPreparedBaseUrl() {
        return prepareUrl(configuration.getBaseUrl());
    }
}

@@ -359,21 +359,22 @@
 %7B%0A%0A    p
-ublic
+rivate
  static 
@@ -419,16 +419,123 @@
 i/json%22;
+%0A    private static final String HTML_WHITESPACE = %22%2520%22;%0A    private static final String WHITESPACE = %22 %22;
 %0A%0A    @A
@@ -780,24 +780,109 @@
 acement());%0A
+        preparedUrl = StringUtils.replace(preparedUrl, HTML_WHITESPACE, WHITESPACE);%0A
         prep

Fix urls with %20 instead of whitespaces