Commit 3e1df632 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Fix accept header when negotiating content

parent c013e8ebf692
......@@ -30,7 +30,6 @@
"react-dom": "^16.2.0"
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/chrome": "0.0.69",
"@types/mocha": "^5.2.5",
"@types/node": "10.11.0",
......@@ -38,7 +37,6 @@
"@types/react": "^16.4.6",
"@types/react-dom": "^16.0.6",
"awesome-typescript-loader": "^5.2.0",
"chai": "^4.2.0",
"copy-webpack-plugin": "^4.5.2",
"mocha": "^5.2.0",
"source-map-loader": "^0.2.3",
......
......@@ -334,7 +334,7 @@ export function getAcceptRdf(includeHTML: boolean): string {
})
.reduce((acc: string, mime: MimeInfo, index: number) => {
if (acc.length === 0) return mime.mime;
return acc + ", " + mime.mime + ";q=" + (1 - 0.1 * index).toString();
return acc + ", " + mime.mime + ";q=" + (1 - 0.1 * index).toPrecision(2).toString();
}, "") + (includeHTML ? ", text/html;q=0.1" : "")
);
}
......@@ -1052,18 +1052,7 @@ export function checkCompliance(data: ResourceData): ComplianceWarning[] {
export function tryNegotiateData(
target: string
): Promise<DocumentSourceLinked> {
let accept = Object.keys(MIME)
.map(key => {
return MIME[key];
})
.sort((x: MimeInfo, y: MimeInfo) => {
return x.priority - y.priority;
})
.reduce((acc: string, mime: MimeInfo, index: number) => {
if (acc.length === 0) return mime.mime;
return acc + ", " + mime.mime + ";q=" + (1 - 0.1 * index).toString();
}, "");
let accept = getAcceptRdf(false);
return new Promise(function(resolve, reject) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment