Skip to content

Commit

Permalink
fix explicit vsicurl prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
notguiltyspark committed Nov 25, 2024
1 parent a4dca08 commit 7f7b6d5
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions src/gui/ogr/qgsgdalguiutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,20 @@ QString QgsGdalGuiUtils::createDatabaseURI( const QString &connectionType, const

QString QgsGdalGuiUtils::createProtocolURI( const QString &type, const QString &url, const QString &configId, const QString &username, const QString &password, bool expandAuthConfig )
{
QString uri;
QString uri = url;
QString prefix;
if ( type == QLatin1String( "vsicurl" ) )
{
uri = url;
// If no protocol is provided in the URL, default to HTTP
if ( !uri.startsWith( "http://" ) && !uri.startsWith( "https://" ) && !uri.startsWith( "ftp://" ) )
prefix = QStringLiteral( "/vsicurl" );
if ( !uri.startsWith( prefix ) )
{
uri.prepend( QStringLiteral( "http://" ) );
// If no protocol is provided in the URL, default to HTTP
if ( !uri.startsWith( "http://" ) && !uri.startsWith( "https://" ) && !uri.startsWith( "ftp://" ) )
{
uri.prepend( QStringLiteral( "http://" ) );
}
uri.prepend( prefix );
}
uri.prepend( QStringLiteral( "/vsicurl/" ) );
}
else if ( type == QLatin1String( "vsis3" )
|| type == QLatin1String( "vsigs" )
Expand All @@ -244,25 +248,40 @@ QString QgsGdalGuiUtils::createProtocolURI( const QString &type, const QString &
|| type == QLatin1String( "vsihdfs" )
)
{
uri = url;
uri.prepend( QStringLiteral( "/%1/" ).arg( type ) );
prefix = QStringLiteral( "/%1/" ).arg( type );
if ( !uri.startsWith( prefix ) )
{
uri.prepend( prefix );
}
}
// catching both GeoJSON and GeoJSONSeq
else if ( type.startsWith( QLatin1String( "GeoJSON" ) ) )
{
uri = url;
// no change needed for now
}
else if ( type == QLatin1String( "CouchDB" ) )
{
uri = QStringLiteral( "couchdb:%1" ).arg( url );
prefix = QStringLiteral( "couchdb:" );
if ( !uri.startsWith( prefix ) )
{
uri.prepend( prefix );
}
}
else if ( type == QLatin1String( "DODS/OPeNDAP" ) )
{
uri = QStringLiteral( "DODS:%1" ).arg( url );
prefix = QStringLiteral( "DODS:" );
if ( !uri.startsWith( prefix ) )
{
uri.prepend( prefix );
}
}
else if ( type == QLatin1String( "WFS3" ) )
{
uri = QStringLiteral( "WFS3:%1" ).arg( url );
prefix = QStringLiteral( "WFS3:" );
if ( !uri.startsWith( prefix ) )
{
uri.prepend( prefix );
}
}
QgsDebugMsgLevel( "Connection type is=" + type + " and uri=" + uri, 2 );
// Update URI with authentication information
Expand Down

0 comments on commit 7f7b6d5

Please sign in to comment.