Express中的查询参数被提取?
我正在为Node.JS编写一个AppleScript应用程序的API。 AppleScript应用程序以下面的forms运行在shell脚本中:
do shell script ("cd " & quoted form of myDir & " curl http://localhost:5000/server.properties?some-value=true&next-value=something%20else&[...] -O")
它打算下载名为server.properties
的文件到基于指定参数的内容的目录myDir
,但由于某种原因,当Express收到请求时,它显示只有当我运行console.log(res.originalUrl)
:
/server.properties?some-value=true
它将把这个请求视为没有其他参数被指定。 任何人都可以告诉我我做错了什么,或者如何找出错误的地方?
编辑原来是我运行shell脚本的方式。 该URL需要被引用,以便&
在shell脚本中不作为操作符。
我的解决scheme如下:
do shell script ("cd " & quoted form of myDir & " curl " & quoted form of (myUrl & myQuery) & " -O")
myUrl
设置为"http://localhost:5000/server.properties"
, myQuery
设置为"?some-value=true&next-value=something%20else&[...]"
。