MCPcopy Create free account
hub / github.com/davidkingzyb/SCAST / _saveServer

Function _saveServer

js/common.js:167–184  ·  view source on GitHub ↗
(content,fileName)

Source from the content-addressed store, hash-verified

165}
166
167function _saveServer(content,fileName){
168 console.log('save to server',fileName)
169 var q = RegExp('[?&]file=([^&]*)').exec(location.href);
170 var file=q && decodeURIComponent(q[1].replace(/\+/g, ' '))
171 if(file&&fileName.indexOf('.tld')>=0)file+='.tld'
172 var fd = new FormData()
173 if(file){
174 fd.append('file', file)
175 }else{
176 fd.append('file', '/tmp/' + fileName)
177 }
178 fd.append('content', content)
179 fetch('/save', { method: "POST", body: fd }).then(resp => {
180 wtfmsg("save file ok")
181 }).catch(err => {
182 console.warn('save err')
183 })
184}
185
186function initFile(){
187 var q = RegExp('[?&]file=([^&]*)').exec(location.href);

Callers 2

loadAstJsonFunction · 0.85
saveScastFunction · 0.85

Calls 2

wtfmsgFunction · 0.85
execMethod · 0.45

Tested by

no test coverage detected