From 20710877948c52d05f5e78dcd31ef41dd1f56119 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Wed, 21 Mar 2018 04:47:26 +0100 Subject: [PATCH] improve detection of file/folder, closes https://github.com/PhilippC/keepass2android/issues/276 --- src/keepass2android/FileSelectHelper.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/keepass2android/FileSelectHelper.cs b/src/keepass2android/FileSelectHelper.cs index 365f981d..337a9c8b 100644 --- a/src/keepass2android/FileSelectHelper.cs +++ b/src/keepass2android/FileSelectHelper.cs @@ -189,9 +189,17 @@ namespace keepass2android private bool ReturnFileOrStartFileChooser(string filename) { - int lastSlashPos = filename.LastIndexOf('/'); - int lastDotPos = filename.LastIndexOf('.'); - if (lastSlashPos >= lastDotPos) //no dot after last slash or == in case neither / nor . + string filenameWithoutProt = filename; + if (filenameWithoutProt.Contains("://")) + { + filenameWithoutProt = + filenameWithoutProt.Substring(filenameWithoutProt.IndexOf("://", StringComparison.Ordinal) + 3); + } + + int lastSlashPos = filenameWithoutProt.LastIndexOf('/'); + int lastDotPos = filenameWithoutProt.LastIndexOf('.'); + if ((lastSlashPos < 0 ) //no slash, probably only a server address (my.server.com) + || (lastSlashPos >= lastDotPos)) //no dot after last slash or == in case neither / nor . { //looks like a folder. return StartFileChooser(filename);