Skip to content

Commit

Permalink
Fix malformed url bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jlinn committed Sep 25, 2017
1 parent 6e4591f commit 40a0cfe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This plugin enables URL tokenization and token filtering by URL part.

| Elasticsearch Version | Plugin Version |
|-----------------------|----------------|
| 2.3.4 | 2.3.4.3 |
| 2.3.4 | 2.3.4.4 |
| 2.3.3 | 2.3.3.5 |
| 2.3.2 | 2.3.2.1 |
| 2.3.1 | 2.3.1.1 |
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-analysis-url</artifactId>
<version>2.3.4.3</version>
<version>2.3.4.4</version>
<packaging>jar</packaging>
<description>Elasticsearch URL token filter plugin</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,10 @@ private List<Token> tokenizeSpecial(URL url) {
// protocol://host
token = getPart(url, URLPart.PROTOCOL) + "://" + getPart(url, URLPart.HOST);
start = getStartIndex(url, token);
end = getEndIndex(start, token);
tokens.add(new Token(token, URLPart.WHOLE, start, end));
if (start != -1) {
end = getEndIndex(start, token);
tokens.add(new Token(token, URLPart.WHOLE, start, end));
}
return tokens;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public void testAnalyze() {
}


@Test
public void testAnalyzePartial() throws Exception {
assertTokensContain("http://", "tokenizer_url_all", ":80", "http:", "http", "80");
}


@Test
public void testAnalyzeWhole() throws Exception {
List<AnalyzeResponse.AnalyzeToken> tokens = analyzeURL("http://foo.bar.com", "tokenizer_url_all_malformed");
Expand Down

0 comments on commit 40a0cfe

Please sign in to comment.