mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-15 17:53:44 +08:00
parent
629ddf7886
commit
7406c1a94f
2 changed files with 9 additions and 4 deletions
|
@ -21,7 +21,7 @@ class DeveloperBarCurlItem extends React.Component
|
|||
|
||||
_onCopyCommand: =>
|
||||
clipboard = require('electron').clipboard
|
||||
clipboard.writeText(@props.item.command)
|
||||
clipboard.writeText(@props.item.commandWithAuth)
|
||||
|
||||
_isError: ->
|
||||
return false if @props.item.statusCode is "pending"
|
||||
|
@ -38,7 +38,7 @@ class DeveloperBarCurlItem extends React.Component
|
|||
fs = require 'fs-plus'
|
||||
if fs.existsSync(curlFile)
|
||||
fs.unlinkSync(curlFile)
|
||||
fs.writeFileSync(curlFile, @props.item.command)
|
||||
fs.writeFileSync(curlFile, @props.item.commandWithAuth)
|
||||
fs.chmodSync(curlFile, '777')
|
||||
{shell} = require 'electron'
|
||||
shell.openItem(curlFile)
|
||||
|
|
|
@ -7,10 +7,13 @@ moment = require 'moment'
|
|||
class DeveloperBarCurlRequest
|
||||
constructor: ({@id, request, statusCode, error}) ->
|
||||
url = request.url
|
||||
urlWithAuth = url
|
||||
if request.auth and (request.auth.user || request.auth.pass)
|
||||
url = url.replace('://', "://#{request.auth.user ? ""}:#{request.auth.pass ? ""}@")
|
||||
urlWithAuth = url.replace('://', "://#{request.auth.user ? ""}:#{request.auth.pass ? ""}@")
|
||||
|
||||
if request.qs
|
||||
url += "?#{qs.stringify(request.qs)}"
|
||||
urlWithAuth += "?#{qs.stringify(request.qs)}"
|
||||
|
||||
postBody = ""
|
||||
postBody = JSON.stringify(request.body).replace(/'/g, '\\u0027') if request.body
|
||||
|
@ -27,7 +30,9 @@ class DeveloperBarCurlRequest
|
|||
tok = request.auth.bearer.replace("!", "\\!")
|
||||
headers += "-H \"Authorization: Bearer #{tok}\" "
|
||||
|
||||
@command = "curl -X #{request.method} #{headers}#{data} \"#{url}\""
|
||||
baseCommand = "curl -X #{request.method} #{headers}#{data}"
|
||||
@command = baseCommand + " \"#{url}\""
|
||||
@commandWithAuth = baseCommand + " \"#{urlWithAuth}\""
|
||||
@statusCode = statusCode ? error?.code ? "pending"
|
||||
@errorMessage = error?.message ? error
|
||||
@startMoment = moment(request.startTime)
|
||||
|
|
Loading…
Reference in a new issue