Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add detection of explicit vsi-prefix in URI-address #59586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://" ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( !uri.startsWith( "http://" ) && !uri.startsWith( "https://" ) && !uri.startsWith( "ftp://" ) )
if ( !uri.startsWith( QLatin1String("http://") ) && !uri.startsWith( QLatin1String("https://") ) && !uri.startsWith( QLatin1String("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
Loading