Requesting HTML with Wrapped URL Safe Scripts
This method wraps each script with various <script></script> tags. It's tuned for embedding HTML file into JSON metadata for NFT tokenURI() method.
This method uses double URL encoded HTML and <script> tags. This way, output doesn't need to be converted to base64.
Supported wrap options:
// wrapType = 0
// Wrap URL Safe method doesn't support inline scripts.
// If you set wrapType to 0, ScrityBuilder will encode the
// given script in base64 and use wrapType 1 wrapping.// wrapType = 1
<script src="data:text/javascript;base64,[SCRIPT]"></script>
// double URL encoded:
// %253Cscript%2520src%253D%2522data%253Atext%252Fjavascript%253Bbase64%252C [SCRIPT] %2522%253E%253C%252Fscript%253E// wrapType = 2
<script type="text/javascript+gzip" src="data:text/javascript;base64,[SCRIPT]"></script>
// double URL encoded:
// %253Cscript%2520type%253D%2522text%252Fjavascript%252Bgzip%2522%2520src%253D%2522data%253Atext%252Fjavascript%253Bbase64%252C [SCRIPT] %2522%253E%253C%252Fscript%253E// wrapType = 3
<script type="text/javascript+png" src="data:text/javascript;base64,[SCRIPT]"></script>
// double URL encoded:
// %253Cscript%2520type%253D%2522text%252Fjavascript%252Bpng%2522%2520src%253D%2522data%253Atext%252Fjavascript%253Bbase64%252C [SCRIPT] %2522%253E%253C%252Fscript%253E// wrapType = anything other than 0, 1, 2, 3
[wrapPrefix][SCRIPT][wrapSuffix]
// wrapPrefix and wrapSuffix should be double URL encodedExample
(bufferSize is set to 100000 as an example. In production, it's important to set an exact size. Please check here to learn more about buffer size.)
HTML file output:
Please note that when wrapType is 1 or 2, stored scripts should be in base64 format.
Last updated