Commit 58d1820d authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Refactoring the extension

parent 77593ca227e7
......@@ -30,7 +30,8 @@ import {
detectDataOnLinks,
fetchObservableAt,
ObservableContent,
observeContent
observeContent,
MIME
} from "../common/data";
import { Message } from "../common/messages";
/// <reference path="./fallback.d.ts"/>
......@@ -120,12 +121,24 @@ function onHeadersReceived(
};
}
let contentType = getHeader(details.responseHeaders, "Content-Type");
index = contentType.indexOf(";");
if (index >= 0) contentType = contentType.substring(0, index);
let observable: ObservableContent = {
content: null,
contentType: getHeader(details.responseHeaders, "Content-Type"),
contentType: contentType,
linkHeader: getHeader(details.responseHeaders, "Link"),
url: details.url
};
if (MIME.hasOwnProperty(observable.contentType)) {
// we should preempt this
return {
redirectUrl:
chrome.extension.getURL("ldbrowser/index.html") +
"?target=" +
encodeURIComponent(details.url)
};
}
let obs = observeContent(observable);
let observation = resolveObservationsForTab(allObservations, details.tabId);
observation.url = obs.url;
......
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