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

geosolutions-it / MapStore2 / 15829819958

23 Jun 2025 04:29PM UTC coverage: 76.979% (+0.03%) from 76.95%
15829819958

Pull #11183

github

web-flow
Merge 124f321fe into 7cde38ac9
Pull Request #11183: #11165: Option to deny app context for normal users

31124 of 48441 branches covered (64.25%)

14 of 16 new or added lines in 5 files covered. (87.5%)

1401 existing lines in 128 files now uncovered.

38752 of 50341 relevant lines covered (76.98%)

36.22 hits per line

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

89.47
/web/client/api/searchText.js
1
/**
2
 * Copyright 2017, 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 { nominatimToGeoJson } from '../utils/GeoCodeUtils';
10
import { generateTemplateString } from '../utils/TemplateUtils';
11
import * as WFS from './WFS';
12

13
const defaultFromTextToFilter = ({searchText, staticFilter, blacklist, item, queriableAttributes, predicate} ) => {
1✔
14
    // split into words and remove blacklisted words
15
    const staticFilterParsed = generateTemplateString(staticFilter || "")(item);
14✔
16
    let searchWords = searchText.split(" ").filter(w => w).filter( w => blacklist.indexOf(w.toLowerCase()) < 0 );
14✔
17

18
    // if the array searchWords is empty, then use the full searchText
19
    if (searchWords.length === 0 ) {
14✔
20
        searchWords = !!searchText ? [searchText] : [];
10!
21
    }
22
    let filter;
23
    if (searchWords.length > 0 ) {
14✔
24
        filter = "(".concat( searchWords.map( (w) => queriableAttributes.map( attr => `${attr} ${predicate} '%${w.replace("'", "''")}%'`).join(" OR ")).join(') AND (')).concat(")");
4✔
25
    }
26

27
    filter = filter ? filter.concat(staticFilterParsed) : staticFilterParsed || null;
14✔
28
    return filter;
14✔
29
};
30
/*
31
 * The API returns a promise for each search service.
32
 * These search services have a particular option that specify how the response is returned.
33
 * 'returnFullData' is a boolean option that if true a the full data is returned, otherwise an array o fearures.
34
*/
35
let Services = {
1✔
36
    nominatim: (searchText, options = {
×
37
        returnFullData: false
38
    }) =>
UNCOV
39
        require('./Nominatim').default
×
40
            .geocode(searchText, options)
41
            .then( res => {return options.returnFullData ? res : nominatimToGeoJson(res.data); }),
×
42
    wfs: (searchText, {url, typeName, queriableAttributes = [], outputFormat = "application/json", predicate = "ILIKE", staticFilter = "", blacklist = [], item, fromTextToFilter = defaultFromTextToFilter, returnFullData = false, ...params }) => {
60!
43
        const filter = fromTextToFilter({searchText, staticFilter, blacklist, item, queriableAttributes, predicate});
16✔
44
        return WFS
16✔
45
            .getFeatureSimple(url, Object.assign({
46
                maxFeatures: 10,
47
                typeName,
48
                outputFormat,
49
                // create a filter like : `(ATTR ilike '%word1%') AND (ATTR ilike '%word2%')`
50
                cql_filter: filter
51
            }, params))
52
            .then( response => {return returnFullData ? response : response.features; } );
16✔
53
    }
54
};
55

56
const Utils = {
1✔
57
    setService: (type, fun) => {
58
        Services[type] = fun;
2✔
59
    },
60
    getService: (type) => {
61
        return !!Services[type] ? Services[type] : null;
19✔
62
    }
63
};
64
export const API = {Services, Utils};
1✔
65

66
export default {API};
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