All files / js/utils APIUtils.js

11.11% Statements 3/27
18.75% Branches 3/16
14.29% Functions 1/7
37.5% Lines 3/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                      1x 5x                
/*
 * Copyright 2020, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */
 
import url from 'url';
/**
* Utilities for api requests
* @name utils.APIUtils
*/
 
/**
* In development mode it returns the request with a relative path
* if the request url contain localhost:8000
* @memberof utils.APIUtils
* @param {string} requestUrl request url
* @return {string} correct url for localhost
*/
export const parseDevHostname = (requestUrl) => {
    if (__DEVTOOLS__ && requestUrl.indexOf('localhost:8000') !== -1) {
        const parsedUrl = url.parse(requestUrl);
        return url.format({
            ...parsedUrl,
            hostname: null,
            host: null,
  I          protocol: null,
            port: null,
            href: null,
            slashes: null
        });
    }
    return requestUrl;
};