diff --git a/src/main/java/org/springframework/hateoas/hal/HalLinkDiscoverer.java b/src/main/java/org/springframework/hateoas/hal/HalLinkDiscoverer.java index 288142f2..49c230d3 100644 --- a/src/main/java/org/springframework/hateoas/hal/HalLinkDiscoverer.java +++ b/src/main/java/org/springframework/hateoas/hal/HalLinkDiscoverer.java @@ -27,6 +27,6 @@ import org.springframework.hateoas.core.JsonPathLinkDiscoverer; public class HalLinkDiscoverer extends JsonPathLinkDiscoverer { public HalLinkDiscoverer() { - super("$._links..%s..href", MediaTypes.HAL_JSON); + super("$._links..['%s']..href", MediaTypes.HAL_JSON); } } diff --git a/src/test/java/org/springframework/hateoas/hal/HalLinkDiscovererUnitTest.java b/src/test/java/org/springframework/hateoas/hal/HalLinkDiscovererUnitTest.java index 09fea7b0..c42f945c 100644 --- a/src/test/java/org/springframework/hateoas/hal/HalLinkDiscovererUnitTest.java +++ b/src/test/java/org/springframework/hateoas/hal/HalLinkDiscovererUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 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. @@ -15,6 +15,10 @@ */ package org.springframework.hateoas.hal; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + +import org.junit.Test; import org.springframework.hateoas.LinkDiscoverer; import org.springframework.hateoas.core.AbstractLinkDiscovererUnitTest; @@ -26,10 +30,17 @@ import org.springframework.hateoas.core.AbstractLinkDiscovererUnitTest; public class HalLinkDiscovererUnitTest extends AbstractLinkDiscovererUnitTest { static final LinkDiscoverer discoverer = new HalLinkDiscoverer(); - static final String SAMPLE = "{ _links : { " + // - "self : { href : 'selfHref' }, " + // - "relation : [ " + // - "{ href : 'firstHref' }, { href : 'secondHref' }]}}"; + static final String SAMPLE = "{ _links : { self : { href : 'selfHref' }, " + // + "relation : [ { href : 'firstHref' }, { href : 'secondHref' }], " + // + "'http://foo.com/bar' : { href : 'fullRelHref' }, " + "}}"; + + /** + * @see #314 + */ + @Test + public void discoversFullyQualifiedRel() { + assertThat(getDiscoverer().findLinkWithRel("http://foo.com/bar", SAMPLE), is(notNullValue())); + } @Override protected LinkDiscoverer getDiscoverer() {