Skip to content

fix(parser): support android-app URI scheme #12

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private Referer parse(String scheme, String host, String path, String query, Str

private Referer parse(String scheme, String host, String path, String query, String pageHost, List<String> internalDomains){

if (scheme == null || (!scheme.equals("http") && !scheme.equals("https"))) return null;
if (scheme == null || (!scheme.equals("http") && !scheme.equals("https") && !scheme.equals("android-app"))) return null;

// Internal link if hosts match exactly
// TODO: would also be nice to:
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/snowplowanalytics/refererparser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,24 @@ public void basicTests() throws URISyntaxException, MalformedURLException, JSONE
result = parser.parse(new URL(u), ref);
assertEquals("URL, String", expected, result.toString());
}

@Test
public void schemeTest() throws URISyntaxException {
// Test different supported schemes
String ref = "m.facebook.com";
String u = "www.example.com";
String expected = "{medium: social, source: Facebook, term: null}";

// http
Referer result = parser.parse(new URI("http://"+ref), new URI(u));
assertEquals("http", expected, result.toString());

// https
result = parser.parse(new URI("https://"+ref), new URI(u));
assertEquals("https", expected, result.toString());

// android-app
result = parser.parse(new URI("android-app://"+ref), new URI(u));
assertEquals("android-app", expected, result.toString());
}
}