Skip to content

Commit

Permalink
Merge pull request #493 from victorlevasseur/upstream_main
Browse files Browse the repository at this point in the history
fix: the header branch selector now properly encode the branch name as an URI
  • Loading branch information
dirkgroot authored Apr 19, 2024
2 parents 2500907 + 7539c22 commit 3705b47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package nl.avisi.structurizr.site.generatr.site.model

import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

data class BranchHomeLinkViewModel(
private val pageViewModel: PageViewModel,
private val branchName: String
) {
val title get() = branchName
val relativeHref get() = HomePageViewModel.url().asUrlToDirectory(pageViewModel.url) + "../$branchName/"
val relativeHref get() = HomePageViewModel.url().asUrlToDirectory(pageViewModel.url) + "../${URLEncoder.encode(branchName, StandardCharsets.UTF_8)}/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ class BranchHomeLinkViewModelTest : ViewModelTest() {
assertThat(viewModel.relativeHref)
.isEqualTo("./../master/")
}

@Test
fun `title is branch name when branch name contains slash`() {
val viewModel = BranchHomeLinkViewModel(pageViewModel(), "feat/branch-1")

assertThat(viewModel.title)
.isEqualTo("feat/branch-1")
}

@Test
fun `relative href from home when branch name contains slash`() {
val viewModel = BranchHomeLinkViewModel(pageViewModel("/"), "feat/branch-1")

assertThat(viewModel.relativeHref)
.isEqualTo("./../feat%2Fbranch-1/")
}
}

0 comments on commit 3705b47

Please sign in to comment.