Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
4
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

20

index.js

@@ -29,3 +29,3 @@ "use strict";

function load(resp) {
let pending, currentPageYOffset;
let initialized, pending, currentPageYOffset;
let elementsToScroll = () => {};

@@ -40,2 +40,3 @@ const stickedElements = [];

const document = Document(resp);
window.document = document;

@@ -45,2 +46,3 @@ const browserContext = {

document,
focus,
runScripts,

@@ -59,6 +61,2 @@ setElementsToScroll,

global.window = window;
window.document = document;
global.document = document;
currentPageYOffset = window.pageYOffset;

@@ -69,4 +67,16 @@

focus();
return browserContext;
function focus() {
if (initialized) {
compile();
}
initialized = true;
global.window = window;
global.document = document;
}
function onDocumentSubmit(event) {

@@ -73,0 +83,0 @@ if (event.target.tagName === "FORM") {

@@ -14,4 +14,4 @@ "use strict";

const location = getLocation(resp.request);
let cookieHeader = getHeaders(resp.request).cookie || "";
const setCookies = {};
const cookieHeader = getHeaders(resp.request).cookie || "";
const cookies = Cookies(cookieHeader);

@@ -61,8 +61,5 @@ const $ = cheerio.load(resp.text, {decodeEntities: false});

Object.defineProperty(document, "cookie", {
get: () => cookieHeader,
get: () => cookies.get(),
set: (value) => {
const parsedCookie = parseSetCookie.call(this, value);
if (!parsedCookie.cookie) throw new Error(`Not a valid cookie: ${value}`);
cookieHeader += parsedCookie.cookie;
cookies.setCookie(value);
}

@@ -145,12 +142,46 @@ });

}
}
function parseSetCookie(cookie) {
const setCookiePattern = /^(\w+)=(.*?)(;(.*?))?$/g;
function Cookies(cookie) {
const setCookiePattern = /^(\w+)=(.*?)(;(.*?))?$/g;
const cookies = loadCookies(cookie);
const setCookies = {};
return {
setCookie,
get
};
function get() {
return Object.keys(cookies).reduce((result, name) => {
const {value} = cookies[name];
result += `${name}=${encodeURIComponent(value)};`;
return result;
}, "");
}
function loadCookies(cookieHeader) {
const cookiesSplit = cookieHeader.split(";");
return cookiesSplit.reduce((result, bar) => {
const parts = bar.split("=");
if (parts.length !== 2) return result;
const name = parts.shift().trim();
if (!name) return result;
const value = decodeURIComponent(parts.shift().trim());
result[name] = {name, value, cookie: bar};
return result;
}, {});
}
function setCookie(cookieString) {
const parsed = {};
if (!/;$/.test(cookie)) cookie = `${cookie};`;
if (!/;$/.test(cookieString)) cookieString = `${cookieString};`;
cookie.trim().replace(setCookiePattern, (match, name, value, settings) => {
cookieString.trim().replace(setCookiePattern, (match, name, value, settings) => {
parsed.cookie = `${name}=${value};`;
parsed.name = name;
parsed.value = decodeURIComponent(value);
parsed.value = decodeURIComponent(value.trim());
Object.assign(parsed, parseSettings(settings));

@@ -160,2 +191,3 @@ });

if (parsed.name) {
cookies[parsed.name] = parsed;
setCookies[parsed.name] = parsed;

@@ -166,14 +198,14 @@ }

}
}
function parseSettings(settings) {
const settingsPattern = /(\w+)=(.*?)(;|$)/g;
const parsed = {};
function parseSettings(settings) {
const settingsPattern = /(\w+)=(.*?)(;|$)/g;
const parsed = {};
settings.replace(settingsPattern, (match, name, value) => {
if (name === "expires") value = new Date(value);
parsed[name] = value;
});
settings.replace(settingsPattern, (match, name, value) => {
if (name === "expires") value = new Date(value);
parsed[name] = value;
});
return parsed;
return parsed;
}
}

@@ -6,4 +6,4 @@ "use strict";

const Element = require("./Element");
const url = require("url");
module.exports = function Window(resp, windowObjects, innerWidth = 760, innerHeight = 760) {

@@ -36,2 +36,6 @@ const emitter = new EventEmitter();

Object.defineProperty(window, "self", {
get: () => window
});
return window;

@@ -52,3 +56,7 @@

function replaceState(ign1, ign2, relativeUrl) {
location.path = relativeUrl;
const newUrl = url.parse(relativeUrl);
location.path = newUrl.path;
location.pathname = newUrl.pathname;
location.search = newUrl.search;
location.href = url.format(location);
}

@@ -55,0 +63,0 @@

{
"name": "@expressen/tallahassee",
"version": "0.6.3",
"version": "0.6.4",
"description": "Expressen client testing framework",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc