Skip to content

Commit

Permalink
fixes for mobile app uris
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Sep 15, 2017
1 parent a24ede3 commit ea1b584
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/App/Services/LoginService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ public async Task<Tuple<IEnumerable<Login>, IEnumerable<Login>>> GetAllAsync(str

Uri uri = null;
string domainName = null;
var androidApp = UriIsAndroidApp(uriString);
var iosApp = UriIsiOSApp(uriString);
var mobileApp = androidApp || iosApp;
var mobileApp = UriIsMobileApp(uriString);

if(!mobileApp &&
(!Uri.TryCreate(uriString, UriKind.Absolute, out uri) ||
Expand All @@ -92,8 +90,7 @@ public async Task<Tuple<IEnumerable<Login>, IEnumerable<Login>>> GetAllAsync(str
return null;
}

var mobileAppInfo = androidApp ? InfoFromAndroidAppUri(uriString) :
iosApp ? InfoFromiOSAppUri(uriString) : null;
var mobileAppInfo = InfoFromMobileAppUri(uriString);
var mobileAppWebUriString = mobileAppInfo?.Item1;
var mobileAppSearchTerms = mobileAppInfo?.Item2;
var eqDomains = (await _settingsService.GetEquivalentDomainsAsync()).Select(d => d.ToArray());
Expand Down Expand Up @@ -157,10 +154,14 @@ public async Task<Tuple<IEnumerable<Login>, IEnumerable<Login>>> GetAllAsync(str
matchingFuzzyLogins.Add(new Login(login));
continue;
}
else if(!mobileApp && Array.IndexOf(matchingDomainsArray, InfoFromAndroidAppUri(loginUriString)) >= 0)
else if(!mobileApp)
{
matchingFuzzyLogins.Add(new Login(login));
continue;
var info = InfoFromMobileAppUri(loginUriString);
if(info?.Item1 != null && Array.IndexOf(matchingDomainsArray, info.Item1) >= 0)
{
matchingFuzzyLogins.Add(new Login(login));
continue;
}
}

Uri loginUri;
Expand Down Expand Up @@ -341,6 +342,20 @@ public async Task<ApiResult> DeleteAttachmentAsync(Login login, string attachmen
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)
{
if(!UriIsAndroidApp(androidAppUriString))
Expand Down Expand Up @@ -371,6 +386,11 @@ private Tuple<string, string[]> InfoFromiOSAppUri(string iosAppUriString)
return new Tuple<string, string[]>(webUri, null);
}

private bool UriIsMobileApp(string uriString)
{
return UriIsAndroidApp(uriString) || UriIsiOSApp(uriString);
}

private bool UriIsAndroidApp(string uriString)
{
return uriString.StartsWith(Constants.AndroidAppProtocol);
Expand Down

0 comments on commit ea1b584

Please sign in to comment.