Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
afbcac9f
Commit
afbcac9f
authored
Nov 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/MimeType: use IterableSplitString() in ParseMimeTypeParameters()
parent
51e5b56b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
MimeType.cxx
src/util/MimeType.cxx
+10
-14
MimeType.hxx
src/util/MimeType.hxx
+1
-1
No files found.
src/util/MimeType.cxx
View file @
afbcac9f
...
...
@@ -18,7 +18,7 @@
*/
#include "MimeType.hxx"
#include "SplitString.hxx"
#include "
Iterable
SplitString.hxx"
#include "StringView.hxx"
std
::
string_view
...
...
@@ -28,21 +28,17 @@ GetMimeTypeBase(std::string_view s) noexcept
}
std
::
map
<
std
::
string
,
std
::
string
>
ParseMimeTypeParameters
(
const
char
*
s
)
noexcept
ParseMimeTypeParameters
(
std
::
string_view
mime_type
)
noexcept
{
std
::
map
<
std
::
string
,
std
::
string
>
result
;
auto
l
=
SplitString
(
s
,
';'
,
true
);
if
(
!
l
.
empty
())
l
.
pop_front
();
/* discard the first segment (the base MIME type) */
const
auto
params
=
StringView
(
mime_type
).
Split
(
';'
).
second
;
for
(
const
auto
&
i
:
l
)
{
const
auto
eq
=
i
.
find
(
'='
);
if
(
eq
==
i
.
npos
)
continue
;
result
.
insert
(
std
::
make_pair
(
i
.
substr
(
0
,
eq
),
i
.
substr
(
eq
+
1
)));
std
::
map
<
std
::
string
,
std
::
string
>
result
;
for
(
auto
i
:
IterableSplitString
(
params
,
';'
))
{
i
.
Strip
();
auto
s
=
i
.
Split
(
'='
);
if
(
!
s
.
second
.
IsNull
())
result
.
emplace
(
s
);
}
return
result
;
...
...
src/util/MimeType.hxx
View file @
afbcac9f
...
...
@@ -42,6 +42,6 @@ GetMimeTypeBase(std::string_view s) noexcept;
* "foo/bar; param1=value1; param2=value2"
*/
std
::
map
<
std
::
string
,
std
::
string
>
ParseMimeTypeParameters
(
const
char
*
s
)
noexcept
;
ParseMimeTypeParameters
(
std
::
string_view
mime_type
)
noexcept
;
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment