fixes for mobile app uris

This commit is contained in:
Kyle Spearrin 2017-09-15 08:12:24 -04:00
parent a24ede364d
commit ea1b584436

View file

@ -81,9 +81,7 @@ namespace Bit.App.Services
Uri uri = null; Uri uri = null;
string domainName = null; string domainName = null;
var androidApp = UriIsAndroidApp(uriString); var mobileApp = UriIsMobileApp(uriString);
var iosApp = UriIsiOSApp(uriString);
var mobileApp = androidApp || iosApp;
if(!mobileApp && if(!mobileApp &&
(!Uri.TryCreate(uriString, UriKind.Absolute, out uri) || (!Uri.TryCreate(uriString, UriKind.Absolute, out uri) ||
@ -92,8 +90,7 @@ namespace Bit.App.Services
return null; return null;
} }
var mobileAppInfo = androidApp ? InfoFromAndroidAppUri(uriString) : var mobileAppInfo = InfoFromMobileAppUri(uriString);
iosApp ? InfoFromiOSAppUri(uriString) : null;
var mobileAppWebUriString = mobileAppInfo?.Item1; var mobileAppWebUriString = mobileAppInfo?.Item1;
var mobileAppSearchTerms = mobileAppInfo?.Item2; var mobileAppSearchTerms = mobileAppInfo?.Item2;
var eqDomains = (await _settingsService.GetEquivalentDomainsAsync()).Select(d => d.ToArray()); var eqDomains = (await _settingsService.GetEquivalentDomainsAsync()).Select(d => d.ToArray());
@ -157,10 +154,14 @@ namespace Bit.App.Services
matchingFuzzyLogins.Add(new Login(login)); matchingFuzzyLogins.Add(new Login(login));
continue; continue;
} }
else if(!mobileApp && Array.IndexOf(matchingDomainsArray, InfoFromAndroidAppUri(loginUriString)) >= 0) else if(!mobileApp)
{ {
matchingFuzzyLogins.Add(new Login(login)); var info = InfoFromMobileAppUri(loginUriString);
continue; if(info?.Item1 != null && Array.IndexOf(matchingDomainsArray, info.Item1) >= 0)
{
matchingFuzzyLogins.Add(new Login(login));
continue;
}
} }
Uri loginUri; Uri loginUri;
@ -341,6 +342,20 @@ namespace Bit.App.Services
return response; return response;
} }
private Tuple<string, string[]> InfoFromMobileAppUri(string mobileAppUriString)
{
if(UriIsAndroidApp(mobileAppUriString))
{
return InfoFromAndroidAppUri(mobileAppUriString);
}
else if(UriIsiOSApp(mobileAppUriString))
{
return InfoFromiOSAppUri(mobileAppUriString);
}
return null;
}
private Tuple<string, string[]> InfoFromAndroidAppUri(string androidAppUriString) private Tuple<string, string[]> InfoFromAndroidAppUri(string androidAppUriString)
{ {
if(!UriIsAndroidApp(androidAppUriString)) if(!UriIsAndroidApp(androidAppUriString))
@ -371,6 +386,11 @@ namespace Bit.App.Services
return new Tuple<string, string[]>(webUri, null); return new Tuple<string, string[]>(webUri, null);
} }
private bool UriIsMobileApp(string uriString)
{
return UriIsAndroidApp(uriString) || UriIsiOSApp(uriString);
}
private bool UriIsAndroidApp(string uriString) private bool UriIsAndroidApp(string uriString)
{ {
return uriString.StartsWith(Constants.AndroidAppProtocol); return uriString.StartsWith(Constants.AndroidAppProtocol);