Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public OAuthConfig(String url, String consumerKey, String consumerSecret) {
consumerSecret == null || consumerSecret.isEmpty()) {
throw new IllegalArgumentException("All arguments are required");
}
this.url = url;
this.url = url.endsWith("/") ? url.substring(0, url.lastIndexOf("/")) : url;
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
}
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/icoderman/woocommerce/oauth/OAuthConfigTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.icoderman.woocommerce.oauth;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class OAuthConfigTest {

@Test
public void removesOneTrailingSlashFromStoreUrl() {
OAuthConfig config = new OAuthConfig(
"https://store.example.com/",
"consumer-key",
"consumer-secret"
);

assertEquals("https://store.example.com", config.getUrl());
}

@Test
public void preservesStoreUrlWithoutTrailingSlash() {
OAuthConfig config = new OAuthConfig(
"https://store.example.com",
"consumer-key",
"consumer-secret"
);

assertEquals("https://store.example.com", config.getUrl());
}
}
Loading