File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -1994,9 +1994,17 @@ QGISEXTERN QVariantMap decodeUri( const QString &uri )
1994
1994
if ( path.indexOf ( ' :' ) != -1 )
1995
1995
{
1996
1996
QStringList parts = path.split ( ' :' );
1997
- path = parts[1 ];
1998
- if ( parts.count () > 2 )
1999
- layerName = parts[2 ];
1997
+ if ( parts[0 ].toLower () == QStringLiteral ( " gpkg" ) )
1998
+ {
1999
+ parts.removeFirst ();
2000
+ // Handle windows paths - which has an extra colon - and unix paths
2001
+ if ( ( parts[0 ].length () > 1 && parts.count () > 1 ) || parts.count () > 2 )
2002
+ {
2003
+ layerName = parts[parts.length () - 1 ];
2004
+ parts.removeLast ();
2005
+ }
2006
+ path = parts.join ( ' :' );
2007
+ }
2000
2008
}
2001
2009
2002
2010
QVariantMap uriComponents;
Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ void TestQgsGdalProvider::decodeUri()
95
95
components = QgsProviderRegistry::instance ()->decodeUri ( QStringLiteral ( " gdal" ), uri );
96
96
QCOMPARE ( components[QStringLiteral ( " path" )].toString (), QStringLiteral ( " /home/to/path/my_file.gpkg" ) );
97
97
QCOMPARE ( components[QStringLiteral ( " layerName" )].toString (), QStringLiteral ( " layer_name" ) );
98
+
99
+ // test windows path
100
+ uri = QStringLiteral ( " gpkg:c:/home/to/path/my_file.gpkg:layer_name" );
101
+ components = QgsProviderRegistry::instance ()->decodeUri ( QStringLiteral ( " gdal" ), uri );
102
+ QCOMPARE ( components[QStringLiteral ( " path" )].toString (), QStringLiteral ( " c:/home/to/path/my_file.gpkg" ) );
103
+ QCOMPARE ( components[QStringLiteral ( " layerName" )].toString (), QStringLiteral ( " layer_name" ) );
98
104
}
99
105
100
106
void TestQgsGdalProvider::scaleDataType ()
You can’t perform that action at this time.
0 commit comments