• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 13548566776

26 Feb 2025 04:23PM UTC coverage: 76.8% (+0.005%) from 76.795%
13548566776

Pull #10882

github

web-flow
Merge 0f517c916 into 6d97cecd0
Pull Request #10882: Fix #10880 Test run failing locally

31293 of 48863 branches covered (64.04%)

23 of 25 new or added lines in 3 files covered. (92.0%)

16 existing lines in 3 files now uncovered.

38847 of 50582 relevant lines covered (76.8%)

35.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/web/client/utils/ProxyUtils.js
1
/**
2
 * Copyright 2015, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import ConfigUtils from './ConfigUtils';
10

11
import { isArray, isObject } from 'lodash';
12

13
export const needProxy = function(uri, config = {}) {
1✔
14
    if ( isArray(uri) ) {
36✔
15
        return uri.reduce((result, current) => needProxy(current) && result, true);
5✔
16
    }
17
    let needed = false;
33✔
18
    let sameOrigin = !(uri.indexOf("http") === 0);
33✔
19
    let urlParts = !sameOrigin && uri.match(/([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/);
33✔
20
    if (urlParts) {
33✔
21
        let location = window.location;
16✔
22
        sameOrigin =
16✔
23
            urlParts[1] === location.protocol &&
28✔
24
            urlParts[3] === location.hostname;
25
        let uPort = urlParts[4];
16✔
26
        let lPort = location.port;
16✔
27
        if (uPort !== 80 && uPort !== "" || lPort !== "80" && lPort !== "") {
16!
28
            sameOrigin = sameOrigin && uPort === lPort;
16✔
29
        }
30
    }
31
    if (!sameOrigin) {
33✔
32
        let proxyUrl = ConfigUtils.getProxyUrl(config);
18✔
33
        if (proxyUrl) {
18!
34
            let useCORS = [];
18✔
35
            if (isObject(proxyUrl)) {
18!
NEW
36
                useCORS = proxyUrl.useCORS || [];
×
NEW
37
                proxyUrl = proxyUrl.url;
×
38
            }
39
            const isCORS = useCORS.reduce((found, current) => found || uri.indexOf(current) === 0, false);
18!
40
            if (!isCORS) {
18!
41
                needed = true;
18✔
42
            }
43
        }
44
    }
45
    return needed;
33✔
46
};
47

48
export const getProxyUrl = function(config = {}) {
1✔
49
    let proxyUrl = ConfigUtils.getProxyUrl(config);
46✔
50
    if (proxyUrl && isObject(proxyUrl)) {
46!
UNCOV
51
        proxyUrl = proxyUrl.url;
×
52
    }
53
    return proxyUrl;
46✔
54
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc