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

skynet-js

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skynet-js - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "skynet-js",
"version": "0.0.3",
"version": "0.0.4",
"description": "Sia Skynet Javascript Client",

@@ -5,0 +5,0 @@ "browser": "src/index.js",

@@ -65,3 +65,3 @@ import parse from "url-parse";

export function download(portalUrl, skylink) {
const url = getUrl(portalUrl, skylink, { download: true });
const url = getUrl(portalUrl, parseSkylink(skylink), { download: true });

@@ -72,3 +72,3 @@ window.open(url, "_blank");

export function open(portalUrl, skylink) {
const url = getUrl(portalUrl, skylink);
const url = getUrl(portalUrl, parseSkylink(skylink));

@@ -81,3 +81,3 @@ window.open(url, "_blank");

parsed.set("pathname", skylink);
parsed.set("pathname", parseSkylink(skylink));

@@ -84,0 +84,0 @@ if (options.download) {

@@ -8,2 +8,10 @@ import axios from "axios";

const skylink = "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg";
const validSkylinkVariations = [
skylink,
`sia:${skylink}`,
`sia://${skylink}`,
`${portalUrl}/${skylink}`,
`${portalUrl}/${skylink}/foo/bar`,
`${portalUrl}/${skylink}?foo=bar`,
];

@@ -24,5 +32,5 @@ describe("SkynetClient", () => {

it("should return correctly formed url", () => {
const url = getUrl(portalUrl, skylink);
expect(url).toEqual(`${portalUrl}/${skylink}`);
validSkylinkVariations.forEach((input) => {
expect(getUrl(portalUrl, input)).toEqual(`${portalUrl}/${skylink}`);
});
});

@@ -41,5 +49,10 @@

download(portalUrl, skylink);
validSkylinkVariations.forEach((input) => {
windowOpen.mockReset();
expect(windowOpen).toHaveBeenCalledWith(`${portalUrl}/${skylink}?attachment=true`, "_blank");
download(portalUrl, input);
expect(windowOpen).toHaveBeenCalledTimes(1);
expect(windowOpen).toHaveBeenCalledWith(`${portalUrl}/${skylink}?attachment=true`, "_blank");
});
});

@@ -52,5 +65,10 @@ });

open(portalUrl, skylink);
validSkylinkVariations.forEach((input) => {
windowOpen.mockReset();
expect(windowOpen).toHaveBeenCalledWith(`${portalUrl}/${skylink}`, "_blank");
open(portalUrl, input);
expect(windowOpen).toHaveBeenCalledTimes(1);
expect(windowOpen).toHaveBeenCalledWith(`${portalUrl}/${skylink}`, "_blank");
});
});

@@ -129,8 +147,5 @@ });

it("should correctly parse skylink out of different strings", () => {
expect(parseSkylink(skylink)).toEqual(skylink);
expect(parseSkylink(`sia:${skylink}`)).toEqual(skylink);
expect(parseSkylink(`sia://${skylink}`)).toEqual(skylink);
expect(parseSkylink(`${portalUrl}/${skylink}`)).toEqual(skylink);
expect(parseSkylink(`${portalUrl}/${skylink}/foo/bar`)).toEqual(skylink);
expect(parseSkylink(`${portalUrl}/${skylink}?foo=bar`)).toEqual(skylink);
validSkylinkVariations.forEach((input) => {
expect(parseSkylink(input)).toEqual(skylink);
});
});

@@ -137,0 +152,0 @@

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