// Copyright 2022 Google Inc. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd #include "packager/kv_pairs/kv_pairs.h" #include "absl/strings/str_split.h" namespace shaka { std::vector SplitStringIntoKeyValuePairs(std::string_view str) { std::vector kv_pairs; // Edge case: 0 pairs. if (str.size() == 0) { return kv_pairs; } std::vector kv_strings = absl::StrSplit(str, '&'); for (const auto& kv_string : kv_strings) { KVPair pair = absl::StrSplit(kv_string, absl::MaxSplits('=', 1)); kv_pairs.push_back(pair); } return kv_pairs; } } // namespace shaka