jamiekurtz / onlineJwtBuilder

Web page used to generate fake, but valid, JSON Web Tokens.
GNU General Public License v3.0
29 stars 17 forks source link

Value copied to clipboard prefaced with two newlines #15

Open kylecombes opened 1 month ago

kylecombes commented 1 month ago

The Bug

The value copied to the clipboard when clicking "Copy JWT to Clipboard" includes two newline characters.

Steps to Reproduce

  1. Open the builder
  2. Click "Create Signed JWT"
  3. Click "Copy JWT to Clipboard"
  4. Paste the value into a text editor

Expected Behavior

The value pasted in the editor should begin with the first alphanumeric character of the JWT and end with the last. There should be no whitespace pasted.

Observed Behavior

Two newlines are inserted prefixing the JWT itself.

Why this is a Problem

I pasted the value into an input that converted the newlines to spaces and I didn't even realize they were there. They eventually caused some problems, and I had to dig until discovering the extraneous whitespace characters. It's not a major issue, but it did cause me some confusion.

kylecombes commented 1 month ago

It seems to be an artifact of using ClipboardJS with a pre element. If I change the pre element to a standard input, set its value to the JWT, and then click the copy button, the JWT is copied without the leading newlines. Perhaps the fix here is to replace the pre with a textarea.