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
4 years ago
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 @@
...
@@ -18,7 +18,7 @@
*/
*/
#include "MimeType.hxx"
#include "MimeType.hxx"
#include "SplitString.hxx"
#include "
Iterable
SplitString.hxx"
#include "StringView.hxx"
#include "StringView.hxx"
std
::
string_view
std
::
string_view
...
@@ -28,21 +28,17 @@ GetMimeTypeBase(std::string_view s) noexcept
...
@@ -28,21 +28,17 @@ GetMimeTypeBase(std::string_view s) noexcept
}
}
std
::
map
<
std
::
string
,
std
::
string
>
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
;
/* discard the first segment (the base MIME type) */
const
auto
params
=
StringView
(
mime_type
).
Split
(
';'
).
second
;
auto
l
=
SplitString
(
s
,
';'
,
true
);
if
(
!
l
.
empty
())
l
.
pop_front
();
for
(
const
auto
&
i
:
l
)
{
std
::
map
<
std
::
string
,
std
::
string
>
result
;
const
auto
eq
=
i
.
find
(
'='
);
for
(
auto
i
:
IterableSplitString
(
params
,
';'
))
{
if
(
eq
==
i
.
npos
)
i
.
Strip
();
continue
;
auto
s
=
i
.
Split
(
'='
);
if
(
!
s
.
second
.
IsNull
())
result
.
insert
(
std
::
make_pair
(
i
.
substr
(
0
,
eq
),
result
.
emplace
(
s
);
i
.
substr
(
eq
+
1
)));
}
}
return
result
;
return
result
;
...
...
This diff is collapsed.
Click to expand it.
src/util/MimeType.hxx
View file @
afbcac9f
...
@@ -42,6 +42,6 @@ GetMimeTypeBase(std::string_view s) noexcept;
...
@@ -42,6 +42,6 @@ GetMimeTypeBase(std::string_view s) noexcept;
* "foo/bar; param1=value1; param2=value2"
* "foo/bar; param1=value1; param2=value2"
*/
*/
std
::
map
<
std
::
string
,
std
::
string
>
std
::
map
<
std
::
string
,
std
::
string
>
ParseMimeTypeParameters
(
const
char
*
s
)
noexcept
;
ParseMimeTypeParameters
(
std
::
string_view
mime_type
)
noexcept
;
#endif
#endif
This diff is collapsed.
Click to expand it.
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