#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:
Oliver Gierke
2016-06-06 11:47:24 +02:00
parent 078e1126c9
commit cbbc2b2d84
2 changed files with 28 additions and 6 deletions

View File

@@ -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")));
}
}