Skip to content

Commit cb4991a

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/npm-dependencies-9a242b5c87
2 parents 8723631 + 8d37aff commit cb4991a

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/App/Controllers/PackageController+routes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ enum PackageController {
7373
documentationMetadata: documentationMetadata
7474
)
7575

76-
case .css, .data, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .svgImages, .svgImg:
76+
case .css, .data, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .svgImages, .svgImg, .videos:
7777
return try await res.encodeResponse(
7878
status: .ok,
7979
headers: req.headers
@@ -448,7 +448,7 @@ extension PackageController {
448448
let path = route.path
449449

450450
switch route.fragment {
451-
case .css, .data, .documentation, .images, .img, .index, .js, .tutorials, .svgImages, .svgImg:
451+
case .css, .data, .documentation, .images, .img, .index, .js, .tutorials, .svgImages, .svgImg, .videos:
452452
return URI(string: "\(baseURL)/\(route.fragment.urlFragment)/\(path)")
453453
case .faviconIco, .faviconSvg, .themeSettings:
454454
return path.isEmpty

Sources/App/Core/DocRoute.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ struct DocRoute: Equatable {
3737
case tutorials
3838
case svgImages
3939
case svgImg
40+
case videos
4041

4142
var contentType: String {
4243
switch self {
4344
case .css:
4445
return "text/css"
45-
case .data, .faviconIco, .faviconSvg, .images, .img, .index:
46+
case .data, .faviconIco, .faviconSvg, .images, .img, .index, .videos:
4647
return "application/octet-stream"
4748
case .linkablePaths, .themeSettings:
4849
return "application/json"
@@ -57,7 +58,7 @@ struct DocRoute: Equatable {
5758

5859
var requiresArchive: Bool {
5960
switch self {
60-
case .css, .data, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .tutorials, .svgImages, .svgImg:
61+
case .css, .data, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .tutorials, .svgImages, .svgImg, .videos:
6162
return false
6263
case .documentation:
6364
return true
@@ -66,7 +67,7 @@ struct DocRoute: Equatable {
6667

6768
var urlFragment: String {
6869
switch self {
69-
case .css, .data, .documentation, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .tutorials:
70+
case .css, .data, .documentation, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .tutorials, .videos:
7071
return rawValue
7172
case .svgImages:
7273
return "images"

Sources/App/routes+documentation.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ func docRoutes(_ app: Application) throws {
8888
let route = try await $0.getDocRoute(fragment: .tutorials)
8989
return try await PackageController.documentation(req: $0, route: route)
9090
}.excludeFromOpenAPI()
91+
app.get(":owner", ":repository", ":reference", "videos", "**") {
92+
let route = try await $0.getDocRoute(fragment: .videos)
93+
return try await PackageController.documentation(req: $0, route: route)
94+
}.excludeFromOpenAPI()
9195
}
9296

9397

@@ -111,7 +115,7 @@ private extension Parameters {
111115
// AND THE FIX
112116
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/pull/3039
113117
return ([archive].compactMap { $0 } + getCatchall()).map { $0.lowercased() }
114-
case .css, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .svgImages, .svgImg:
118+
case .css, .faviconIco, .faviconSvg, .images, .img, .index, .js, .linkablePaths, .themeSettings, .svgImages, .svgImg, .videos:
115119
return getCatchall()
116120
}
117121
}

Tests/AppTests/RoutesTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ final class RoutesTests: AppTestCase {
6161
}
6262
}
6363

64+
func test_documentation_videos() async throws {
65+
try await withDependencies {
66+
$0.environment.awsDocsBucket = { "docs-bucket" }
67+
} operation: {
68+
// setup
69+
Current.fetchDocumentation = { _, _ in .init(status: .ok) }
70+
71+
// MUT
72+
try await app.test(.GET, "foo/bar/1.2.3/videos/baz.mov") { res async in
73+
// validation
74+
XCTAssertEqual(res.status, .ok)
75+
}
76+
}
77+
}
78+
6479
func test_openapi() async throws {
6580
try await app.test(.GET, "openapi/openapi.json") { res async in
6681
XCTAssertEqual(res.status, .ok)

0 commit comments

Comments
 (0)