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

@perspect3vism/ad4m

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perspect3vism/ad4m - npm Package Compare versions

Comparing version 0.1.22 to 0.1.23

9

lib/src/expression/ExpressionRef.js

@@ -45,3 +45,10 @@ "use strict";

function parseExprUrl(url) {
const URIregexp = /^([^:^\s]+):\/\/([^\s]+)$/;
if (url.startsWith("literal://")) {
const languageRef = new LanguageRef_1.LanguageRef();
languageRef.address = 'literal';
languageRef.name = 'literal';
const content = url.substring(10);
return new ExpressionRef(languageRef, content);
}
const URIregexp = /^([^:^\s]+):\/\/([\s\S]+)$/;
const URImatches = URIregexp.exec(url);

@@ -48,0 +55,0 @@ if (URImatches && URImatches.length == 3) {

@@ -5,4 +5,6 @@ export declare class Literal {

static from(literal: any): Literal;
encodeSingleQuote(input: string): string;
decodeSingleQuote(input: string): string;
toUrl(): string;
get(): any;
}

@@ -33,2 +33,15 @@ "use strict";

}
encodeSingleQuote(input) {
console.log('encodeSingleQuote');
//@ts-ignore
input = input.split("'").join("\\'");
console.log(input);
return input;
}
decodeSingleQuote(input) {
console.log('decodeSingleQuote');
//@ts-ignore
input = input.split("\\'").join("'");
return input;
}
toUrl() {

@@ -51,3 +64,3 @@ if (__classPrivateFieldGet(this, _Literal_url, "f") && !__classPrivateFieldGet(this, _Literal_literal, "f"))

}
return `literal://${encoded}`;
return this.encodeSingleQuote(encodeURI(`literal://${encoded}`));
}

@@ -62,3 +75,3 @@ get() {

// get rid of "literal://"
const encoded = __classPrivateFieldGet(this, _Literal_url, "f").substring(10);
const encoded = decodeURI(this.decodeSingleQuote(__classPrivateFieldGet(this, _Literal_url, "f").substring(10)));
if (encoded.startsWith("string:")) {

@@ -65,0 +78,0 @@ return encoded.substring(7);

4

lib/src/Literal.test.js

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

const testString = "test string";
const testUrl = "literal://string:test string";
const testUrl = "literal://string:test%20string";
expect(Literal_1.Literal.from(testString).toUrl()).toBe(testUrl);

@@ -20,3 +20,3 @@ expect(Literal_1.Literal.fromUrl(testUrl).get()).toBe(testString);

const testObject = { testString: "test", testNumber: "1337" };
const testUrl = "literal://json:{\"testString\":\"test\",\"testNumber\":\"1337\"}";
const testUrl = "literal://json:%7B%22testString%22:%22test%22,%22testNumber%22:%221337%22%7D";
expect(Literal_1.Literal.from(testObject).toUrl()).toBe(testUrl);

@@ -23,0 +23,0 @@ expect(Literal_1.Literal.fromUrl(testUrl).get()).toStrictEqual(testObject);

{
"name": "@perspect3vism/ad4m",
"version": "0.1.22",
"version": "0.1.23",
"description": "*The Agent-Centric Distributed Application Meta-ontology* or just: *Agent-Centric DApp Meta-ontology* * A new meta-ontology for interoperable, decentralized application design * A spanning-layer to enable seamless integration between Holochain DNAs, blockchains, linked-data structures/ontologies and centralized back-ends * The basis for turning distinct, monolithic and siloed apps into a global, open and interoperable sense-making network",

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

@@ -30,3 +30,11 @@ import type { Address } from '../Address';

export function parseExprUrl(url: string): ExpressionRef {
const URIregexp = /^([^:^\s]+):\/\/([^\s]+)$/
if(url.startsWith("literal://")) {
const languageRef = new LanguageRef()
languageRef.address = 'literal'
languageRef.name = 'literal'
const content = url.substring(10)
return new ExpressionRef(languageRef, content)
}
const URIregexp = /^([^:^\s]+):\/\/([\s\S]+)$/
const URImatches = URIregexp.exec(url)

@@ -33,0 +41,0 @@

@@ -6,3 +6,3 @@ import { Literal } from './Literal'

const testString = "test string"
const testUrl = "literal://string:test string"
const testUrl = "literal://string:test%20string"
expect(Literal.from(testString).toUrl()).toBe(testUrl)

@@ -21,3 +21,3 @@ expect(Literal.fromUrl(testUrl).get()).toBe(testString)

const testObject = {testString: "test", testNumber: "1337"}
const testUrl = "literal://json:{\"testString\":\"test\",\"testNumber\":\"1337\"}"
const testUrl = "literal://json:%7B%22testString%22:%22test%22,%22testNumber%22:%221337%22%7D"
expect(Literal.from(testObject).toUrl()).toBe(testUrl)

@@ -24,0 +24,0 @@ expect(Literal.fromUrl(testUrl).get()).toStrictEqual(testObject)

@@ -19,2 +19,17 @@ export class Literal {

encodeSingleQuote(input: string) {
console.log('encodeSingleQuote')
//@ts-ignore
input = input.split("'").join("\\'")
console.log(input)
return input
}
decodeSingleQuote(input: string) {
console.log('decodeSingleQuote')
//@ts-ignore
input = input.split("\\'").join("'")
return input
}
toUrl(): string {

@@ -39,3 +54,3 @@ if(this.#url && !this.#literal)

return `literal://${encoded}`
return this.encodeSingleQuote(encodeURI(`literal://${encoded}`))
}

@@ -52,5 +67,5 @@

throw new Error("Can't render Literal from non-literal URL")
// get rid of "literal://"
const encoded = this.#url.substring(10)
const encoded = decodeURI(this.decodeSingleQuote(this.#url.substring(10)))

@@ -57,0 +72,0 @@ if(encoded.startsWith("string:")) {

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

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