From e44d5805e5fb444e2cd4b67c83eca15ad6fc664e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 12 Jul 2024 14:53:55 +0000 Subject: [PATCH] Decode URIs somewhat --- index.html | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 2e4735c..f017f43 100644 --- a/index.html +++ b/index.html @@ -173,7 +173,40 @@ document.getElementById("result").innerHTML = "Address is BIP 353-invalid - it contains no bitcoin: URI"; return; } - document.getElementById("result").innerHTML = "Opening your bitcoin wallet to pay " + name + "! If it doesn't work, click here."; + var addr_ty_table = ""; + const base_and_params = bip353.substring(8).split("?"); + if (base_and_params[0].length != 0) { + if (!/^[\p{ASCII}]*$/u.test(base_and_params[0])) { + addr_ty_table += "On-Chain Non-Private AddressInvalid"; + } else { + addr_ty_table += "On-Chain Non-Private Address" + base_and_params[0] + ""; + } + } + if (base_and_params.length > 1 && base_and_params[1].length > 0) { + for (const param of base_and_params[1].split("&")) { + const key_value = param.split("="); + if (key_value.length == 2 && key_value[1].length != 0) { + var value = ""; + if (!/^[\p{ASCII}]*$/u.test(key_value[1])) { + value = "Invalid"; + } else if (key_value[1].length < 75) { + value = "" + key_value[1] + ""; + } else { + value = "" + key_value[1].substring(0, 75) + "..."; + } + if (key_value[0] == "lno") { + addr_ty_table += "BOLT 12 Offer" + value + ""; + } else if (key_value[0] == "sp") { + addr_ty_table += "Silent Payments" + value + ""; + } + } + } + } + const result_elem = document.getElementById("result"); + result_elem.innerHTML = "Opening your bitcoin wallet to pay " + name + "! If it doesn't work, click here."; + if (addr_ty_table != "") { + result_elem.innerHTML += "
" + addr_ty_table + "
TypeAddress
"; + } window.location = bip353; } }); -- 2.39.5