fix: unable to decode json string with prefix or suffix contains space or line break

This commit is contained in:
tiny-craft 2023-11-02 16:27:55 +08:00
parent 37e31b1636
commit 67666f4edf
3 changed files with 21 additions and 18 deletions

View File

@ -117,10 +117,11 @@ func autoDecode(str string) (value, resultDecode string) {
return
}
if value, ok = decodeDeflate(str); ok {
resultDecode = types.DECODE_DEFLATE
return
}
// FIXME: skip decompress with deflate due to incorrect format checking
//if value, ok = decodeDeflate(str); ok {
// resultDecode = types.DECODE_DEFLATE
// return
//}
if value, ok = decodeZStd(str); ok {
resultDecode = types.DECODE_ZSTD
@ -202,6 +203,7 @@ func autoViewAs(str string) (value, resultFormat string) {
}
func decodeJson(str string) (string, bool) {
str = strings.TrimSpace(str)
if (strings.HasPrefix(str, "{") && strings.HasSuffix(str, "}")) ||
(strings.HasPrefix(str, "[") && strings.HasSuffix(str, "]")) {
var out bytes.Buffer

View File

@ -91,4 +91,18 @@ const onDropdownShow = (show) => {
</n-dropdown>
</template>
<style lang="scss" scoped></style>
<style lang="scss">
.type-selector-header {
height: 30px;
line-height: 30px;
font-size: 15px;
font-weight: bold;
text-align: center;
padding: 0 10px;
}
.type-selector-item {
min-width: 100px;
text-align: center;
}
</style>

View File

@ -121,19 +121,6 @@ body {
padding-right: 10px;
}
.type-selector-header {
height: 30px;
line-height: 30px;
font-size: 15px;
font-weight: bold;
text-align: center;
}
.type-selector-item {
min-width: 100px;
text-align: center;
}
.nav-pane-container {
overflow: hidden;