@plattar/plattar-qrcode 1.148.2 → 1.150.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -232,7 +232,7 @@ class BaseElement extends HTMLElement {
232
232
  }
233
233
 
234
234
  _IsFetchAPISupported() {
235
- return 'fetch' in window;
235
+ return "fetch" in window;
236
236
  }
237
237
 
238
238
  _ShortenURL(url) {
@@ -242,17 +242,30 @@ class BaseElement extends HTMLElement {
242
242
  }
243
243
 
244
244
  try {
245
- const b64 = btoa(url);
246
- const endpoint = "https://c2.plattar.space/api/v2/shorten?base64=" + b64;
247
-
248
- fetch(endpoint).then((response) => {
245
+ const b64Link = new Buffer(url).toString("base64");
246
+
247
+ fetch("https://c.plattar.com/shorten", {
248
+ cache: "no-store",
249
+ method: "POST",
250
+ headers: {
251
+ "Content-Type": "application/json",
252
+ },
253
+ body: JSON.stringify({
254
+ data: {
255
+ attributes: {
256
+ url: b64Link,
257
+ isBase64: true
258
+ }
259
+ }
260
+ })
261
+ }).then((response) => {
249
262
  if (!response.ok) {
250
263
  throw new Error("PlattarQR._ShortenURL() - response was invalid");
251
264
  }
252
265
 
253
- return response.text();
254
- }).then((text) => {
255
- return accept(text);
266
+ return response.json();
267
+ }).then((json) => {
268
+ return accept(json.data.attributes.url);
256
269
  }).catch(() => {
257
270
  return reject(new Error("PlattarQR._ShortenURL() - there was an unexpected issue generating short url"));
258
271
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-qrcode",
3
- "version": "1.148.2",
3
+ "version": "1.150.1",
4
4
  "description": "Allows embedding Plattar-Style QR Codes for existing websites.",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/cli": "^7.21.0",
47
- "@babel/core": "^7.21.3",
48
- "@babel/preset-env": "^7.20.2",
47
+ "@babel/core": "^7.21.4",
48
+ "@babel/preset-env": "^7.21.4",
49
49
  "browserify": "^17.0.0",
50
50
  "uglify-es": "^3.3.9"
51
51
  },
package/version.js CHANGED
@@ -1 +1 @@
1
- module.exports = "1.148.2";
1
+ module.exports = "1.150.1";