Change MIME mapping for .js from application/javascript to text/javascript

This application/javascript MIME type is deprecated.

This commit therefore changes the MIME type mapping for *.js files from
application/javascript to text/javascript in order to align with
industry standards.

Closes gh-33197
This commit is contained in:
Sam Brannen 2024-07-12 18:15:18 +02:00
parent 59b9404956
commit 3e48498663
6 changed files with 12 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ public class WebSpringJupiterTests {
void resources() throws Exception {
this.mockMvc.perform(get("/resources/Spring.js"))
.andExpectAll(
content().contentType("application/javascript"),
content().contentType("text/javascript"),
content().string(containsString("Spring={};"))
);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ public class WebAppResourceTests {
testClient.get().uri("/resources/Spring.js")
.exchange()
.expectStatus().isOk()
.expectHeader().contentType("application/javascript")
.expectHeader().contentType("text/javascript")
.expectBody(String.class).value(containsString("Spring={};"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -67,7 +67,7 @@ public class WebAppResourceTests {
@Test
public void resourceRequest() throws Exception {
this.mockMvc.perform(get("/resources/Spring.js"))
.andExpect(content().contentType("application/javascript"))
.andExpect(content().contentType("text/javascript"))
.andExpect(content().string(containsString("Spring={};")));
}

View File

@ -146,7 +146,7 @@ application/ipfix ipfix
application/java-archive jar
application/java-serialized-object ser
application/java-vm class
application/javascript js
# application/javascript js
# application/jose
# application/jose+json
# application/jrd+json
@ -1686,7 +1686,7 @@ text/csv csv
# text/fwdred
# text/grammar-ref-list
text/html html htm
# text/javascript
text/javascript js
# text/jcr-cnd
# text/markdown
# text/mizar

View File

@ -30,7 +30,7 @@ class MediaTypeFactoryTests {
@Test
void getMediaType() {
assertThat(MediaTypeFactory.getMediaType("file.xml")).contains(MediaType.APPLICATION_XML);
assertThat(MediaTypeFactory.getMediaType("file.js")).contains(MediaType.parseMediaType("application/javascript"));
assertThat(MediaTypeFactory.getMediaType("file.js")).contains(MediaType.parseMediaType("text/javascript"));
assertThat(MediaTypeFactory.getMediaType("file.css")).contains(MediaType.parseMediaType("text/css"));
assertThat(MediaTypeFactory.getMediaType("file.foobar")).isNotPresent();
}

View File

@ -606,7 +606,7 @@ class ResourceWebHandlerTests {
setBestMachingPattern(exchange, "/**");
this.handler.handle(exchange).block(TIMEOUT);
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(MediaType.parseMediaType("application/javascript"));
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(MediaType.parseMediaType("text/javascript"));
assertResponseBody(exchange, "function foo() { console.log(\"hello world\"); }");
}
@ -619,12 +619,11 @@ class ResourceWebHandlerTests {
this.handler.handle(exchange).block(TIMEOUT);
HttpHeaders headers = exchange.getResponse().getHeaders();
assertThat(headers.getContentType()).isEqualTo(MediaType.parseMediaType("application/javascript"));
assertThat(headers.getContentType()).isEqualTo(MediaType.parseMediaType("text/javascript"));
assertResponseBody(exchange, "function foo() { console.log(\"hello world\"); }");
}
@Test
// gh-27538, gh-27624
@Test // gh-27538, gh-27624
void filterNonExistingLocations() throws Exception {
this.handler.afterPropertiesSet();
ResourceWebHandler handler = new ResourceWebHandler();