]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/util.js
Fixed failing tests from dompdf chanages
[bookstack] / resources / js / services / util.js
index b44b7de6c2f62365e20fbddba8fda6b51115c0b8..de2ca20c13eb934b00a475b817489e9fa29d9670 100644 (file)
@@ -60,4 +60,14 @@ export function escapeHtml(unsafe) {
         .replace(/>/g, ">")
         .replace(/"/g, """)
         .replace(/'/g, "'");
+}
+
+/**
+ * Generate a random unique ID.
+ *
+ * @returns {string}
+ */
+export function uniqueId() {
+    const S4 = () => (((1+Math.random())*0x10000)|0).toString(16).substring(1);
+    return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
 }
\ No newline at end of file