Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search URL bug fix #107

Merged
merged 2 commits into from
Nov 8, 2024
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 @@ -18,7 +18,7 @@ class SearchModule {
@Singleton
fun providesSearchApi(): SearchApi {
return Retrofit.Builder()
.baseUrl(SearchConfig.BASE_URL)
.baseUrl(SearchConfig.API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(SearchApi::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package uk.govuk.app.search.domain

object SearchConfig {
val BASE_URL = "https://www.gov.uk"

// Search API V1 ===>
// val BASE_URL = "https://www.gov.uk"
// val API_BASE_URL = "https://www.gov.uk"
// const val SEARCH_PATH = "/api/search.json"
// const val DESCRIPTION_RESPONSE_FIELD = "description"

// Search API V2 ===>
val BASE_URL = "https://search.publishing.service.gov.uk"
val API_BASE_URL = "https://search.publishing.service.gov.uk"
const val SEARCH_PATH = "/v0_1/search.json"
// field has both changed name and is now optional!
const val DESCRIPTION_RESPONSE_FIELD = "description_with_highlighting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package uk.govuk.app.search.domain

import org.junit.Assert.assertEquals
import org.junit.Test
import uk.govuk.app.search.domain.SearchConfig.BASE_URL

class StringUtilsTest {
@Test
fun `buildFullUrl returns a full url when given a path`() {
val url = StringUtils.buildFullUrl("/hello-world")

assertEquals("${BASE_URL}/hello-world", url)
assertEquals("https://www.gov.uk/hello-world", url)
}

@Test
Expand Down