File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
main/java/ac/simons/oembed
test/java/ac/simons/oembed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 5656 */
5757public class OembedEndpoint {
5858
59+ private static final Pattern FORMAT_PLACE_HOLDER_PATTERN = Pattern .compile ("(?i)%?\\ {format}" );
60+
5961 /**
6062 * The name of this provider.
6163 */
@@ -272,8 +274,9 @@ public URI toApiUrl(final String url) {
272274 String uri ;
273275 final List <NameValuePair > query = new ArrayList <>();
274276
275- if (this .getEndpoint ().toLowerCase ().contains ("%{format}" )) {
276- uri = this .getEndpoint ().replaceAll (Pattern .quote ("%{format}" ), this .getFormat ().toString ());
277+ var matcher = FORMAT_PLACE_HOLDER_PATTERN .matcher (this .getEndpoint ());
278+ if (matcher .find ()) {
279+ uri = matcher .replaceAll (this .getFormat ().toString ());
277280 }
278281 else {
279282 uri = this .getEndpoint ();
Original file line number Diff line number Diff line change @@ -107,6 +107,19 @@ public void toApiUrlShouldWork() {
107107 "https://api.twitter.com/1.1/statuses/oembed.json?url=https%3A%2F%2Ftwitter.com%2Frotnroll666%2Fstatus%2F549898095853838336" );
108108 }
109109
110+ @ Test // GH-16
111+ public void vimeoWithoutPercentage () {
112+ OembedEndpoint oembedEndpoint = new OembedEndpoint ();
113+
114+ oembedEndpoint .setEndpoint ("https://vimeo.com/api/oembed.{format}" );
115+ oembedEndpoint .setFormat (Format .json );
116+ oembedEndpoint .setMaxWidth (null );
117+ oembedEndpoint .setMaxHeight (null );
118+
119+ assertThat (oembedEndpoint .toApiUrl ("http://vimeo.com/channels/everythinganimated/111627831" )).hasToString (
120+ "https://vimeo.com/api/oembed.json?url=http%3A%2F%2Fvimeo.com%2Fchannels%2Feverythinganimated%2F111627831" );
121+ }
122+
110123 @ Test
111124 public void toApiUrlShouldWork2 () {
112125
You can’t perform that action at this time.
0 commit comments