File tree 2 files changed +20
-4
lines changed
2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -48,24 +48,28 @@ export const getFeatureSimple = function(baseUrl, params) {
48
48
export const getCapabilitiesURL = ( url , { version = "1.1.0" } = { } ) => {
49
49
const parsed = urlUtil . parse ( getDefaultUrl ( url ) , true ) ;
50
50
return urlUtil . format ( assign ( { } , parsed , {
51
+ search : undefined , // this allows to merge parameters correctly
51
52
query : assign ( {
52
- service : "WFS" ,
53
53
version,
54
+ ...parsed . query ,
55
+ service : "WFS" ,
54
56
request : "GetCapabilities"
55
- } , parsed . query )
57
+ } )
56
58
} ) ) ;
57
59
} ;
58
60
59
61
export const getFeatureURL = ( url , typeName , { version = "1.1.0" , ...params } = { } ) => {
60
62
const parsed = urlUtil . parse ( getDefaultUrl ( url ) , true ) ;
61
63
return urlUtil . format ( assign ( { } , parsed , {
64
+ search : undefined , // this allows to merge parameters correctly
62
65
query : assign ( {
63
- service : "WFS" ,
64
66
typeName,
65
67
version,
68
+ ...parsed . query ,
69
+ service : "WFS" ,
66
70
request : "GetFeature" ,
67
71
...params
68
- } , parsed . query )
72
+ } )
69
73
} ) ) ;
70
74
} ;
71
75
/**
Original file line number Diff line number Diff line change @@ -150,4 +150,16 @@ describe('Test WFS ogc API functions', () => {
150
150
expect ( getFeatureURL ( _url ) . split ( '?' ) [ 0 ] ) . toBe ( _url [ 0 ] ) ;
151
151
} ) ;
152
152
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
+ } ) ;
153
165
} ) ;
You can’t perform that action at this time.
0 commit comments