@slipmatio/toolbelt
Advanced tools
Comparing version 0.2.1 to 0.2.2
# Changelog | ||
## 0.2.2 (2024-01-05) | ||
- Feat: allow passing Router instance to `getNextPath`. | ||
## 0.2.1 (2024-01-05) | ||
- Fix: package.json is now more Vite -compatible. | ||
## 0.2.0 (2024-01-05) | ||
- Feat: added `getNextPath` | ||
- Refactor: refactored internals | ||
- Feat: added `getNextPath`. | ||
- Refactor: refactored internals. | ||
- Chore: bumped deps. | ||
@@ -8,0 +16,0 @@ |
@@ -0,1 +1,3 @@ | ||
import { Router } from 'vue-router'; | ||
/** | ||
@@ -13,4 +15,5 @@ * Simple clipboard copy for modern browsers. Returns true if successful. | ||
* Helper for figuring our ?next= query param in a safe way. | ||
* Pass the router instance whenever not used directly from script setup block. | ||
*/ | ||
export declare function getNextPath(): string; | ||
export declare function getNextPath(router?: Router): string; | ||
@@ -17,0 +20,0 @@ /** |
@@ -1,26 +0,26 @@ | ||
import { useRoute as c } from "vue-router"; | ||
function s(o) { | ||
let t; | ||
o === "localStorage" ? t = window.localStorage : t = window.sessionStorage; | ||
import { useRoute as i } from "vue-router"; | ||
function l(o) { | ||
let e; | ||
o === "localStorage" ? e = window.localStorage : e = window.sessionStorage; | ||
try { | ||
const e = "__storage_test__"; | ||
return t.setItem(e, e), t.removeItem(e), !0; | ||
} catch (e) { | ||
return e instanceof DOMException && // everything except Firefox | ||
(e.code === 22 || // Firefox | ||
e.code === 1014 || // test name field too, because code might not be present | ||
const t = "__storage_test__"; | ||
return e.setItem(t, t), e.removeItem(t), !0; | ||
} catch (t) { | ||
return t instanceof DOMException && // everything except Firefox | ||
(t.code === 22 || // Firefox | ||
t.code === 1014 || // test name field too, because code might not be present | ||
// everything except Firefox | ||
e.name === "QuotaExceededError" || // Firefox | ||
e.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored | ||
t && t.length !== 0; | ||
t.name === "QuotaExceededError" || // Firefox | ||
t.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored | ||
e && e.length !== 0; | ||
} | ||
} | ||
function l(o) { | ||
let t = ""; | ||
function s(o) { | ||
let e = ""; | ||
if (document.cookie && document.cookie !== "") { | ||
const e = document.cookie.split(";"); | ||
for (let n = 0; n < e.length; n++) { | ||
const r = e[n].trim(); | ||
const t = document.cookie.split(";"); | ||
for (let n = 0; n < t.length; n++) { | ||
const r = t[n].trim(); | ||
if (r.substring(0, o.length + 1) === o + "=") { | ||
t = decodeURIComponent(r.substring(o.length + 1)); | ||
e = decodeURIComponent(r.substring(o.length + 1)); | ||
break; | ||
@@ -30,9 +30,9 @@ } | ||
} | ||
return t.length > 0 ? t : null; | ||
return e.length > 0 ? e : null; | ||
} | ||
function a(o) { | ||
const t = document; | ||
const e = document; | ||
try { | ||
const e = document.createElement("input"); | ||
return e.setAttribute("style", "opacity:0;"), e.setAttribute("value", o), t.body.appendChild(e), e.select(), t.execCommand("copy"), t.body.removeChild(e), !0; | ||
const t = document.createElement("input"); | ||
return t.setAttribute("style", "opacity:0;"), t.setAttribute("value", o), e.body.appendChild(t), t.select(), e.execCommand("copy"), e.body.removeChild(t), !0; | ||
} catch { | ||
@@ -42,15 +42,16 @@ return !1; | ||
} | ||
function i(o) { | ||
function c(o) { | ||
return typeof o == "string"; | ||
} | ||
function d() { | ||
const o = c(); | ||
function d(o) { | ||
let e; | ||
o ? e = o.currentRoute.value : e = i(); | ||
let t = "/"; | ||
return o.query && o.query.next && i(o.query.next) && o.query.next.startsWith("/") && (t = o.query.next), t; | ||
return e.query && e.query.next && c(e.query.next) && e.query.next.startsWith("/") && (t = e.query.next), t; | ||
} | ||
export { | ||
a as copyToClipboard, | ||
l as getCookie, | ||
s as getCookie, | ||
d as getNextPath, | ||
s as storageAvailable | ||
l as storageAvailable | ||
}; |
{ | ||
"name": "@slipmatio/toolbelt", | ||
"type": "module", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"main": "dist/toolbelt.umd.cjs", | ||
@@ -6,0 +6,0 @@ "module": "dist/toolbelt.js", |
@@ -17,3 +17,3 @@ # Slipmat Toolbelt | ||
- `getNextPath(): string` - returns the value of `?next` query param or `/` | ||
- `getNextPath(router?: Router): string` - returns the value of `?next` query param or `/` | ||
@@ -20,0 +20,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
7969
80