I have the following HTML code:
<a href="data:text/x-c;charset=utf-8,struct%20example%20%7B%0A%09int%20number%20%3D%205%3B%0A%7D%3B"
download="example.cpp" target="_blank">Download a struct stub</a>
but for some reason, clicking this anchor results downloading an example.cp
file and not example.cpp
. I think I've checked everything. For instance, for .json
files it works correctly. Also text/x-c
is the right Content-Type
for .cpp
files. I've also tried with text/plain
, but it still kept getting changed to .cp
. Why does this happen and is there a workaround to it? I'm using Google Chrome.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…