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

xml-js-builder

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-js-builder - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

lib/XMLElementBuilder.d.ts

@@ -15,5 +15,5 @@ import { XMLElement } from './XMLElement';

findNamespace(namespace: string): string;
protected static exportFindNamespace(element: XMLElementBuilder): (() => any) | ((ns: string) => string);
protected static exportFindNamespace(element: XMLElementBuilder): (ns: string) => string;
add<T>(element: any[]): T[];
add<T>(element: any): T;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var XML_1 = require("./XML");
function setFreeNamespaceName(leftName, rightName, attributes) {
var kname = 'a';
var value = leftName + ':';
while (attributes['xmlns:' + kname] !== undefined || value.indexOf(kname + ':') === 0) {
var newChar = kname.charCodeAt(0) + 1;
if (newChar > 'z'.charCodeAt(0))
kname = 'x' + String.fromCharCode(newChar);
else
kname = kname.substr(0, kname.length - 1) + String.fromCharCode(newChar);
}
attributes['xmlns:' + kname] = value;
return kname + ':' + rightName;
}
function explodeName(name, attributes, findNamespaceInParents) {
var li1 = name.lastIndexOf(':');
var li2 = name.indexOf(':');
var li1 = Math.max(name.lastIndexOf(':'), name.lastIndexOf('/'));
if (li1 === -1)

@@ -17,33 +29,3 @@ return name;

return name;
var kname = 'a';
var value = leftName + ':';
while (attributes['xmlns:' + kname] !== undefined || value.indexOf(kname + ':') === 0) {
var newChar = kname.charCodeAt(0) + 1;
if (newChar > 'z'.charCodeAt(0))
kname = 'x' + String.fromCharCode(newChar);
else
kname = kname.substr(0, kname.length - 1) + String.fromCharCode(newChar);
}
attributes['xmlns:' + kname] = value;
name = kname + ':' + rightName;
return name;
/*
const lindex = Math.max(li1 === li2 && name.indexOf('DAV:') !== 0 ? -1 : li1, name.lastIndexOf('/')) + 1;
if(lindex !== 0)
{
let kname = 'a';
const value = name.substring(0, lindex);
while(attributes['xmlns:' + kname] !== undefined || value.indexOf(kname + ':') === 0)
{
const newChar = kname.charCodeAt(0) + 1;
if(newChar > 'z'.charCodeAt(0))
kname = 'x' + String.fromCharCode(newChar);
else
kname = kname.substr(0, kname.length - 1) + String.fromCharCode(newChar);
}
attributes['xmlns:' + kname] = value;
name = kname + ':' + name.substring(lindex);
}
return name;*/
return setFreeNamespaceName(leftName, rightName, attributes);
}

@@ -55,5 +37,11 @@ var XMLElementBuilder = (function () {

this.parent = parent;
this.name = explodeName(name, attributes, XMLElementBuilder.exportFindNamespace(parent));
this.attributes = attributes;
var slashLastIndex = name.lastIndexOf('/');
if (slashLastIndex > -1) {
var leftName = name.substring(0, slashLastIndex);
var rightName = name.substring(slashLastIndex + 1);
name = setFreeNamespaceName(leftName, rightName, this.attributes);
}
this.name = name;
this.type = 'element';
this.attributes = attributes;
this.elements = [];

@@ -84,6 +72,2 @@ }

XMLElementBuilder.exportFindNamespace = function (element) {
if (!element || !element.findNamespace)
return function () {
return undefined;
};
return function (ns) {

@@ -90,0 +74,0 @@ return element.findNamespace(ns);

@@ -20,3 +20,3 @@ {

"name": "xml-js-builder",
"version": "1.0.2",
"version": "1.0.3",
"author": "Adrien Castex <adrien.castex@gmail.com>",

@@ -23,0 +23,0 @@ "license": "Unlicense",

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