Skip to content

Commit

Permalink
feat: curl command in different os
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Aug 13, 2020
1 parent 4d7cbf7 commit 2ea37d9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/SubmitFlag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
<v-divider></v-divider>
<br>
<p>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">curl
-X POST {{baseURL}}/api/flag -H 'Authorization: {{info.Token}}' -d '{ "flag": "your_flag_here"
}'</code>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">{{getCurlCommand()}}</code>
</p>
</v-card-text>
</v-card>
Expand All @@ -44,7 +42,6 @@
data: () => ({
info: null,
inputFlag: '',
baseURL: window.location.origin,
message: '',
snackBarVisible: false,
Expand Down Expand Up @@ -78,6 +75,13 @@
this.snackBarColor = 'error'
this.snackBarVisible = true
});
},
getCurlCommand() {
// The curl command is different in windows and *nix os.
if ((navigator.platform === "Win32") || (navigator.platform === "Windows")) {
return `curl -X POST ${window.location.origin}/api/flag -H "Authorization: ${this.info.Token}" -d "{ \\"flag\\": \\"your_flag_here\\" }"`
}
return `curl -X POST ${window.location.origin}/api/flag -H 'Authorization: ${this.info.Token}' -d '{ "flag": "your_flag_here" }'`
}
}
}
Expand Down

0 comments on commit 2ea37d9

Please sign in to comment.