nadesiko3 3.3.24 → 3.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nadesiko3",
3
- "version": "3.3.24",
3
+ "version": "3.3.25",
4
4
  "description": "Japanese Programming Language",
5
5
  "main": "src/index.mjs",
6
6
  "bin": {
@@ -40,7 +40,7 @@ const server = http.createServer(function (req, res) {
40
40
  const q = String(a[1]).split('&')
41
41
  for (const kv of q) {
42
42
  const qq = kv.split('=')
43
- params[qq[0]] = decodeURI(qq[1])
43
+ params[qq[0]] = decodeURIComponent(qq[1])
44
44
  }
45
45
  }
46
46
  // サニタイズ
@@ -62,6 +62,15 @@ const server = http.createServer(function (req, res) {
62
62
  apiRun(res, params)
63
63
  return
64
64
  }
65
+ if (uri === '/get_new_filename') {
66
+ res.writeHead(200, { 'Content-Type': 'text/plaing; charset=utf-8' })
67
+ res.end('"new.nako3"')
68
+ return
69
+ }
70
+ if (uri === '/deletefile') {
71
+ apiDelete(res, params)
72
+ return
73
+ }
65
74
 
66
75
  // ファイルパスを生成
67
76
  let filePath = path.join(rootDir, uri)
@@ -191,3 +200,18 @@ function apiRun (res, params) {
191
200
  res.end('error')
192
201
  }
193
202
  }
203
+
204
+ function apiDelete (res, params) {
205
+ const fname = params.file
206
+ const body = params.body
207
+ const fullpath = path.join(userDir, fname)
208
+ try {
209
+ fs.unlinkSync(fullpath)
210
+ res.writeHead(200, { 'Content-Type': 'text/plaing; charset=utf-8' })
211
+ res.end('"ok"')
212
+ return
213
+ } catch (err) {
214
+ res.writeHead(200, { 'Content-Type': 'text/plaing; charset=utf-8' })
215
+ res.end('error:' + err.message)
216
+ }
217
+ }