This repository has been archived by the owner on Feb 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3053 from wordpress-mobile/fix-wpapi-login-http
[Woo] Fix Site Credentials login when site discovery fails and site has http to https redirection
- Loading branch information
Showing
3 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/WPAPIDiscoveryUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.wordpress.android.fluxc.network.rest.wpapi | ||
|
||
import org.wordpress.android.fluxc.utils.extensions.slashJoin | ||
import org.wordpress.android.util.UrlUtils | ||
|
||
internal object WPAPIDiscoveryUtils { | ||
fun buildDefaultRESTBaseUrl( | ||
url: String | ||
): String { | ||
val urlWithoutScheme = UrlUtils.removeScheme(url) | ||
val httpsUrl = UrlUtils.addUrlSchemeIfNeeded(urlWithoutScheme, true) | ||
|
||
// TODO investigate the possibility to use `/?rest_route=` instead, | ||
// `/wp-json` works only when permalinks are enabled, where `/?rest_route=` works without them | ||
// fallback to ".../wp-json/" | ||
return httpsUrl.slashJoin("wp-json") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters