File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
main/kotlin/org/modelix/model/server/handlers
test/kotlin/org/modelix/model/server/handlers Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 1
1
package org.modelix.model.server.handlers
2
2
3
+ import io.ktor.http.encodeURLPathPart
3
4
import io.ktor.server.application.Application
4
5
import io.ktor.server.application.call
5
6
import io.ktor.server.html.respondHtmlTemplate
6
7
import io.ktor.server.routing.get
7
8
import io.ktor.server.routing.routing
8
9
import kotlinx.html.FlowContent
10
+ import kotlinx.html.FlowOrInteractiveOrPhrasingContent
9
11
import kotlinx.html.a
10
12
import kotlinx.html.h1
11
13
import kotlinx.html.i
@@ -74,9 +76,7 @@ class RepositoryOverview(private val repoManager: RepositoriesManager) {
74
76
}
75
77
}
76
78
td {
77
- a(" ../history/${branch.repositoryId.id} /${branch.branchName} /" ) {
78
- + " Show History"
79
- }
79
+ buildHistoryLink(branch.repositoryId.id, branch.branchName)
80
80
}
81
81
td {
82
82
val latestVersion = repoManager.getVersion(branch)
@@ -94,3 +94,9 @@ class RepositoryOverview(private val repoManager: RepositoriesManager) {
94
94
}
95
95
}
96
96
}
97
+
98
+ fun FlowOrInteractiveOrPhrasingContent.buildHistoryLink (repositoryId : String , branchName : String ) {
99
+ a(" ../history/${repositoryId.encodeURLPathPart()} /${branchName.encodeURLPathPart()} /" ) {
100
+ + " Show History"
101
+ }
102
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.modelix.model.server.handlers
18
+
19
+ import kotlinx.html.span
20
+ import kotlinx.html.stream.createHTML
21
+ import kotlin.test.Test
22
+ import kotlin.test.assertEquals
23
+
24
+ class RepositoryOverviewTest {
25
+
26
+ @Test
27
+ fun testSlashesInPathSegmentsFromRepositoryIdAndBranchId () {
28
+ val html = createHTML().span {
29
+ buildHistoryLink(" repository/v1" , " branch/v2" )
30
+ }
31
+ assertEquals(" <span><a href=\" ../history/repository%2Fv1/branch%2Fv2/\" >Show History</a></span>" , html)
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments