fix: sync devtools frontend mime types with upstream (#25780)
* fix: sync devtools frontend mime types with upstream * fix header
This commit is contained in:
parent
f31a1c9e4e
commit
a5ca25ba65
1 changed files with 15 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "chrome/common/webui_url_constants.h"
|
||||
|
@ -22,7 +23,12 @@ namespace electron {
|
|||
namespace {
|
||||
|
||||
std::string PathWithoutParams(const std::string& path) {
|
||||
return GURL(std::string("devtools://devtools/") + path).path().substr(1);
|
||||
return GURL(base::StrCat({content::kChromeDevToolsScheme,
|
||||
url::kStandardSchemeSeparator,
|
||||
chrome::kChromeUIDevToolsHost}))
|
||||
.Resolve(path)
|
||||
.path()
|
||||
.substr(1);
|
||||
}
|
||||
|
||||
std::string GetMimeTypeForPath(const std::string& path) {
|
||||
|
@ -33,11 +39,19 @@ std::string GetMimeTypeForPath(const std::string& path) {
|
|||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "text/css";
|
||||
} else if (base::EndsWith(filename, ".js",
|
||||
base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(filename, ".mjs",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "application/javascript";
|
||||
} else if (base::EndsWith(filename, ".png",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "image/png";
|
||||
} else if (base::EndsWith(filename, ".map",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "application/json";
|
||||
} else if (base::EndsWith(filename, ".ts",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "application/x-typescript";
|
||||
} else if (base::EndsWith(filename, ".gif",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "image/gif";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue