function shorten(text, length) const t = document.createElement('input') t.maxlength = length t.value = text return t.value }
function shorten(text, length) { return new Promise((a, r) => fetch(`http://leftpad.io/shorten?l=${length}&v=${encodeURIComponent(text)}`).then(rx=>rx.text().then(a, r), r)); }
$ host leftpad.io Host leftpad.io not found: 3(NXDOMAIN)
https://developer.mozilla.org/en-US/docs/Web/API/URL
I even has the possibility to inspect the element and actually see what's going on.
Needs more Kubernetes and a service mesh.
const shorten = (text, length) => text.substring(0, length);