Skip to content

A full-featured download manager.

feat: add parseHeader util for restart task dialog

Dr_rOot37b446b6f030
diff --git a/src/shared/utils.js b/src/shared/utils.js
index 21d5b4f8..1a24c2a9 100644
--- a/src/shared/utils.js
+++ b/src/shared/utils.js
@@ -531,3 +531,22 @@ export function diffConfig (current = {}, next = {}) {
export function calcFormLabelWidth (locale) {
return locale.startsWith('de') ? '28%' : '23%'
}
+
+export function parseHeader (header = '') {
+ header = header.trim()
+ let result = {}
+ if (!header) {
+ return result
+ }
+
+ const headers = splitTextRows(header)
+ headers.forEach((line) => {
+ const index = line.indexOf(':')
+ const name = line.substr(0, index)
+ const value = line.substr(index + 1).trim()
+ result[name] = value
+ })
+ result = changeKeysToCamelCase(result)
+
+ return result
+}