Skip to content

Commit

Permalink
Avoid '?&' for prev/next link query string
Browse files Browse the repository at this point in the history
  • Loading branch information
pathmapper authored and nyalldawson committed Apr 1, 2023
1 parent 6ef6414 commit 53a71e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/server/services/wfs3/qgswfs3handlers.cpp
Expand Up @@ -1383,6 +1383,10 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c
{
cleanedUrlAsString += '?';
}
else
{
cleanedUrlAsString += '&';
}

// Get the self link
json selfLink;
Expand All @@ -1399,7 +1403,7 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c
if ( offset != 0 )
{
json prevLink = selfLink;
prevLink["href"] = QStringLiteral( "%1&offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::max<long>( 0, offset - limit ) ).arg( limit ).toStdString();
prevLink["href"] = QStringLiteral( "%1offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::max<long>( 0, offset - limit ) ).arg( limit ).toStdString();
prevLink["rel"] = "prev";
prevLink["title"] = "Previous page";
data["links"].push_back( prevLink );
Expand All @@ -1408,7 +1412,7 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c
if ( limit + offset < matchedFeaturesCount )
{
json nextLink = selfLink;
nextLink["href"] = QStringLiteral( "%1&offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::min<long>( matchedFeaturesCount, limit + offset ) ).arg( limit ).toStdString();
nextLink["href"] = QStringLiteral( "%1offset=%2&limit=%3" ).arg( cleanedUrlAsString ).arg( std::min<long>( matchedFeaturesCount, limit + offset ) ).arg( limit ).toStdString();
nextLink["rel"] = "next";
nextLink["title"] = "Next page";
data["links"].push_back( nextLink );
Expand Down
Expand Up @@ -33,7 +33,7 @@ Content-Type: application/geo+json
"type": "text/html"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?&offset=1&limit=1",
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?offset=1&limit=1",
"rel": "next",
"title": "Next page",
"type": "application/geo+json"
Expand Down
Expand Up @@ -33,13 +33,13 @@ Content-Type: application/geo+json
"type": "text/html"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?&offset=0&limit=1",
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?offset=0&limit=1",
"rel": "prev",
"title": "Previous page",
"type": "application/geo+json"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?&offset=2&limit=1",
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?offset=2&limit=1",
"rel": "next",
"title": "Next page",
"type": "application/geo+json"
Expand Down
Expand Up @@ -33,7 +33,7 @@ Content-Type: application/geo+json
"type": "text/html"
},
{
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?&offset=1&limit=1",
"href": "http://server.qgis.org/wfs3/collections/testlayer èé/items?offset=1&limit=1",
"rel": "prev",
"title": "Previous page",
"type": "application/geo+json"
Expand Down

0 comments on commit 53a71e5

Please sign in to comment.