Comparing version 0.0.3 to 0.0.4
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16411
230