#440 - Links now parses URIs containing commas correctly.
Switched to a regular expression based split of links to make sure URIs that contain commas do not interfere with the rather simplified splitting algorithm we used before.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,7 @@ public class LinksUnitTest {
|
||||
|
||||
static final String FIRST = "</something>;rel=\"foo\"";
|
||||
static final String SECOND = "</somethingElse>;rel=\"bar\"";
|
||||
static final String WITH_COMMA = "<http://localhost:8080/test?page=0&filter=foo,bar>;rel=\"foo\"";
|
||||
|
||||
static final String LINKS = StringUtils.collectionToCommaDelimitedString(Arrays.asList(FIRST, SECOND));
|
||||
|
||||
@@ -60,4 +61,20 @@ public class LinksUnitTest {
|
||||
public void getSingleLinkByRel() {
|
||||
assertThat(reference.getLink("bar"), is(new Link("/somethingElse", "bar")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #440
|
||||
*/
|
||||
@Test
|
||||
public void parsesLinkWithComma() {
|
||||
|
||||
Link withComma = new Link("http://localhost:8080/test?page=0&filter=foo,bar", "foo");
|
||||
|
||||
assertThat(Links.valueOf(WITH_COMMA).getLink("foo"), is(withComma));
|
||||
|
||||
Links twoWithCommaInFirst = Links.valueOf(WITH_COMMA.concat(",").concat(SECOND));
|
||||
|
||||
assertThat(twoWithCommaInFirst.getLink("foo"), is(withComma));
|
||||
assertThat(twoWithCommaInFirst.getLink("bar"), is(new Link("/somethingElse", "bar")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user