Skip to content

Commit e6d1789

Browse files
geosolutions-it#10193: Issue with WFS added via Query params (geosolutions-it#10195)
* geosolutions-it#10193: Issue with WFS added via Query params - fix the issue behind not adding the wfs layer - write the unit tests for this cahnge * Update web/client/api/WFS.js --------- Co-authored-by: Suren <[email protected]>
1 parent f4f323b commit e6d1789

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

web/client/api/WFS.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,28 @@ export const getFeatureSimple = function(baseUrl, params) {
4848
export const getCapabilitiesURL = (url, {version = "1.1.0"} = {}) => {
4949
const parsed = urlUtil.parse(getDefaultUrl(url), true);
5050
return urlUtil.format(assign({}, parsed, {
51+
search: undefined, // this allows to merge parameters correctly
5152
query: assign({
52-
service: "WFS",
5353
version,
54+
...parsed.query,
55+
service: "WFS",
5456
request: "GetCapabilities"
55-
}, parsed.query)
57+
})
5658
}));
5759
};
5860

5961
export const getFeatureURL = (url, typeName, { version = "1.1.0", ...params } = {}) => {
6062
const parsed = urlUtil.parse(getDefaultUrl(url), true);
6163
return urlUtil.format(assign({}, parsed, {
64+
search: undefined, // this allows to merge parameters correctly
6265
query: assign({
63-
service: "WFS",
6466
typeName,
6567
version,
68+
...parsed.query,
69+
service: "WFS",
6670
request: "GetFeature",
6771
...params
68-
}, parsed.query)
72+
})
6973
}));
7074
};
7175
/**

web/client/api/__tests__/WFS-test.js

+12
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,16 @@ describe('Test WFS ogc API functions', () => {
150150
expect(getFeatureURL(_url).split('?')[0]).toBe(_url[0]);
151151
});
152152

153+
it('getFeatureURL if it includes getCapabilites request', () => {
154+
const _url = 'http://gs-stable.geosolutionsgroup.com:443/geoserver3/wfs?service=WFS&version=1.1.0&request=GetCapabilities';
155+
const featureURL = getFeatureURL(_url, "layerName");
156+
expect(featureURL.includes("request=GetFeature")).toBeTruthy();
157+
expect(featureURL.split('?')[1]).toEqual('typeName=layerName&version=1.1.0&service=WFS&request=GetFeature');
158+
});
159+
160+
it('getFeatureURL if it includes normal getFeature request with version different than the default one', () => {
161+
const _url = 'http://gs-stable.geosolutionsgroup.com:443/geoserver3/wfs?service=WFS&version=1.1.1&request=GetFeature';
162+
const featureURL = getFeatureURL(_url, "layerName");
163+
expect(featureURL.split('?')[1]).toEqual('typeName=layerName&version=1.1.1&service=WFS&request=GetFeature');
164+
});
153165
});

0 commit comments

Comments
 (0)