Skip to content

Commit 270109b

Browse files
committed
Fixed Java referer-parser doesn't work on Hadoop (fixes #76)
1 parent 3d65fa7 commit 270109b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

java-scala/CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 0.2.2 (2014-07-23)
2+
--------------------------
3+
Fixed Java referer-parser doesn't work on Hadoop (#76)
4+
15
Version 0.2.1 (2014-07-16)
26
--------------------------
37
Updated build process for local Maven publishing (#72)

java-scala/src/main/java/com/snowplowanalytics/refererparser/Parser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public Referer parse(URI refererUri, String pageHost, List<String> internalDomai
117117
}
118118

119119
public Referer parse(URL refererUrl, String pageHost){
120-
if(refererUrl == null) { return null; }
120+
if (refererUrl == null) { return null; }
121121
return parse(refererUrl.getProtocol(), refererUrl.getHost(), refererUrl.getPath(), refererUrl.getQuery(), pageHost);
122122
}
123123

@@ -202,9 +202,12 @@ private String extractSearchTerm(String query, List<String> possibleParameters)
202202

203203
List<NameValuePair> params;
204204
try {
205-
params = URLEncodedUtils.parse(query, Charset.forName("UTF-8"));
205+
params = URLEncodedUtils.parse(new URI("http://localhost?" + query), "UTF-8");
206+
// params = URLEncodedUtils.parse(query, Charset.forName("UTF-8")); because https://github.com/snowplow/referer-parser/issues/76
206207
} catch (IllegalArgumentException iae) {
207208
return null;
209+
} catch (URISyntaxException use) { // For new URI
210+
return null;
208211
}
209212

210213
for (NameValuePair pair : params) {

0 commit comments

Comments
 (0)