@@ -343,6 +343,22 @@ class PackageController_routesTests: SnapshotTestCase {
343
343
try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . data, pathElements: [ " path " ] ) ) . string,
344
344
" http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/data/path "
345
345
)
346
+ XCTAssertEqual (
347
+ try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . images, pathElements: [ " path " ] ) ) . string,
348
+ " http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/images/path "
349
+ )
350
+ XCTAssertEqual (
351
+ try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . img, pathElements: [ " path " ] ) ) . string,
352
+ " http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/img/path "
353
+ )
354
+ XCTAssertEqual (
355
+ try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . svgImages, pathElements: [ " path " ] ) ) . string,
356
+ " http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/images/path "
357
+ )
358
+ XCTAssertEqual (
359
+ try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . svgImg, pathElements: [ " path " ] ) ) . string,
360
+ " http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/img/path "
361
+ )
346
362
XCTAssertEqual (
347
363
try PackageController . awsDocumentationURL ( route: . init( owner: " Foo " , repository: " Bar " , docVersion: . reference( " 1.2.3 " ) , fragment: . js, pathElements: [ " path " ] ) ) . string,
348
364
" http://docs-bucket.s3-website.us-east-2.amazonaws.com/foo/bar/1.2.3/js/path "
@@ -427,6 +443,27 @@ class PackageController_routesTests: SnapshotTestCase {
427
443
" /owner/repo/canonical-ref/documentation/archive/symbol:$-% " )
428
444
}
429
445
446
+ func test_documentation_routes_contentType( ) async throws {
447
+ try await app. test ( . GET, " /owner/package/main/images/foo/bar.jpeg " ) { res async in
448
+ XCTAssertEqual ( res. headers. contentType, . init( type: " application " , subType: " octet-stream " ) )
449
+ }
450
+ try await app. test ( . GET, " /owner/package/main/images/foo/bar.svg " ) { res async in
451
+ XCTAssertEqual ( res. headers. contentType, . init( type: " image " , subType: " svg+xml " ) )
452
+ }
453
+ try await app. test ( . GET, " /owner/package/main/images/foo/bar.SVG " ) { res async in
454
+ XCTAssertEqual ( res. headers. contentType, . init( type: " image " , subType: " svg+xml " ) )
455
+ }
456
+ try await app. test ( . GET, " /owner/package/main/img/foo/bar.jpeg " ) { res async in
457
+ XCTAssertEqual ( res. headers. contentType, . init( type: " application " , subType: " octet-stream " ) )
458
+ }
459
+ try await app. test ( . GET, " /owner/package/main/img/foo/bar.svg " ) { res async in
460
+ XCTAssertEqual ( res. headers. contentType, . init( type: " image " , subType: " svg+xml " ) )
461
+ }
462
+ try await app. test ( . GET, " /owner/package/main/img/foo/bar.SVG " ) { res async in
463
+ XCTAssertEqual ( res. headers. contentType, . init( type: " image " , subType: " svg+xml " ) )
464
+ }
465
+ }
466
+
430
467
func test_documentation_routes_redirect( ) async throws {
431
468
// Test the redirect documentation routes without any reference:
432
469
// /owner/package/documentation + various path elements
0 commit comments