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

acrolinx-sidebar-sdk

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acrolinx-sidebar-sdk - npm Package Compare versions

Comparing version 0.4.12 to 0.4.13

3

dist/utils/sidebar-loader.d.ts

@@ -15,2 +15,5 @@ import { AcrolinxPluginConfig } from "../acrolinx-plugin";

export declare function loadSidebarCode(sidebarUrl?: string): void;
export declare function grepAttributeValues(html: string, attribute: string): string[];
export declare function rebaseRelativeUrl(url: string, sidebarBaseUrl: string): string;
export declare function loadSidebarIntoIFrame(config: AcrolinxPluginConfig, sidebarIFrameElement: HTMLIFrameElement, onSidebarLoaded: () => void): void;
export declare function rebaseRelativeUrls(sidebarHtml: string, sidebarBaseUrl: string): string;

@@ -13,3 +13,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("lodash");
var utils = require("./utils");

@@ -59,3 +58,2 @@ exports.SIDEBAR_URL = 'https://sidebar-classic.acrolinx-cloud.com/v14/prod/';

var sidebarBaseUrl = sidebarUrl;
var getAbsoluteAttributeValue = function (s) { return s.replace(/^.*"(.*)".*$/g, sidebarBaseUrl + '$1'); };
var completeSidebarUrl = createCompleteSidebarUrl(sidebarBaseUrl);

@@ -74,7 +72,8 @@ utils.fetch(completeSidebarUrl, function (sidebarHtml) {

var head = document.querySelector('head');
var css = _.map(withoutComments.match(/href=".*?"/g) || [], getAbsoluteAttributeValue);
var makeRelativeUrlsAbsolutToSidebar = function (url) { return rebaseRelativeUrl(url, sidebarBaseUrl); };
var css = grepAttributeValues(withoutComments, 'href').map(makeRelativeUrlsAbsolutToSidebar);
css.forEach(function (ref) {
head.appendChild(createCSSLinkElement(ref));
});
var scripts = _.map(withoutComments.match(/src=".*?"/g) || [], getAbsoluteAttributeValue);
var scripts = grepAttributeValues(withoutComments, 'src').map(makeRelativeUrlsAbsolutToSidebar);
scripts.forEach(function (ref) {

@@ -86,2 +85,23 @@ head.appendChild(createScriptElement(ref));

exports.loadSidebarCode = loadSidebarCode;
// Exported only for testing
function grepAttributeValues(html, attribute) {
var regexp = new RegExp(attribute + "=\"(.*?)\"", 'g');
var matches;
var result = [];
while ((matches = regexp.exec(html)) !== null) {
result.push(matches[1]);
}
return result;
}
exports.grepAttributeValues = grepAttributeValues;
// Exported only for testing
function rebaseRelativeUrl(url, sidebarBaseUrl) {
if (url.match(/^https?:/)) {
return url;
}
else {
return sidebarBaseUrl + url;
}
}
exports.rebaseRelativeUrl = rebaseRelativeUrl;
function loadSidebarIntoIFrame(config, sidebarIFrameElement, onSidebarLoaded) {

@@ -112,5 +132,3 @@ if (config.sidebarHtml) {

}
var sidebarHtmlWithAbsoluteLinks = sidebarHtml
.replace(/src="/g, 'src="' + sidebarBaseUrl)
.replace(/href="/g, 'href="' + sidebarBaseUrl);
var sidebarHtmlWithAbsoluteLinks = rebaseRelativeUrls(sidebarHtml, sidebarBaseUrl);
injectSidebarHtml(sidebarHtmlWithAbsoluteLinks, sidebarIFrameElement);

@@ -122,2 +140,9 @@ onSidebarLoaded();

exports.loadSidebarIntoIFrame = loadSidebarIntoIFrame;
// Exported only for testing
function rebaseRelativeUrls(sidebarHtml, sidebarBaseUrl) {
return sidebarHtml
.replace(/src="(?!https?:)/g, 'src="' + sidebarBaseUrl)
.replace(/href="(?!https?:)/g, 'href="' + sidebarBaseUrl);
}
exports.rebaseRelativeUrls = rebaseRelativeUrls;
function injectSidebarHtml(sidebarHtml, sidebarIFrameElement) {

@@ -124,0 +149,0 @@ var sidebarContentWindow = sidebarIFrameElement.contentWindow;

2

package.json
{
"name": "acrolinx-sidebar-sdk",
"description": "Acrolinx Sidebar SDK for JavaScript",
"version": "0.4.12",
"version": "0.4.13",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Acrolinx",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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