aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/flow/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/flow/utils.js')
-rw-r--r--web/src/js/flow/utils.js25
1 files changed, 8 insertions, 17 deletions
diff --git a/web/src/js/flow/utils.js b/web/src/js/flow/utils.js
index d72febaa..d64e2d55 100644
--- a/web/src/js/flow/utils.js
+++ b/web/src/js/flow/utils.js
@@ -1,12 +1,12 @@
-var _ = require("lodash");
-var $ = require("jquery");
+import _ from "lodash";
+import $ from "jquery";
var defaultPorts = {
"http": 80,
"https": 443
};
-var MessageUtils = {
+export var MessageUtils = {
getContentType: function (message) {
var ct = this.get_first_header(message, /^Content-Type$/i);
if(ct){
@@ -58,7 +58,7 @@ var MessageUtils = {
}
};
-var RequestUtils = _.extend(MessageUtils, {
+export var RequestUtils = _.extend(MessageUtils, {
pretty_host: function (request) {
//FIXME: Add hostheader
return request.host;
@@ -72,11 +72,11 @@ var RequestUtils = _.extend(MessageUtils, {
}
});
-var ResponseUtils = _.extend(MessageUtils, {});
+export var ResponseUtils = _.extend(MessageUtils, {});
var parseUrl_regex = /^(?:(https?):\/\/)?([^\/:]+)?(?::(\d+))?(\/.*)?$/i;
-var parseUrl = function (url) {
+export var parseUrl = function (url) {
//there are many correct ways to parse a URL,
//however, a mitmproxy user may also wish to generate a not-so-correct URL. ;-)
var parts = parseUrl_regex.exec(url);
@@ -109,22 +109,13 @@ var parseUrl = function (url) {
var isValidHttpVersion_regex = /^HTTP\/\d+(\.\d+)*$/i;
-var isValidHttpVersion = function (httpVersion) {
+export var isValidHttpVersion = function (httpVersion) {
return isValidHttpVersion_regex.test(httpVersion);
};
-var parseHttpVersion = function (httpVersion) {
+export var parseHttpVersion = function (httpVersion) {
httpVersion = httpVersion.replace("HTTP/", "").split(".");
return _.map(httpVersion, function (x) {
return parseInt(x);
});
};
-
-module.exports = {
- ResponseUtils: ResponseUtils,
- RequestUtils: RequestUtils,
- MessageUtils: MessageUtils,
- parseUrl: parseUrl,
- parseHttpVersion: parseHttpVersion,
- isValidHttpVersion: isValidHttpVersion
-}; \ No newline at end of file