Last active
September 2, 2022 20:52
-
-
Save unyo/9baeb7909de80ff0923706ee2370aa6c to your computer and use it in GitHub Desktop.
Curl to Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://jsbin.com/datafudezo/1/edit?js,output | |
const input = ``; // paste your curl from chrome here | |
const action = input.match(/curl '([^']+)'/)[1]; | |
const data = input.match(/data-raw '([^']+)'/)[1].split('&'); | |
const inputs = data.map(function(keyval) { | |
const [key, val] = keyval.split('='); | |
return '<label for="'+key+'">'+key+'</label><br /><input type="text" id="'+key+'" name="'+key+'" value="'+val+'" /><br />'; | |
}); | |
document.write('<form action="'+action+'">'+inputs.join('\n')+'<input type="submit" /></form>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment