1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/signaling/jid_util.h"
7 #include "base/strings/string_util.h"
11 std::string
NormalizeJid(const std::string
& jid
) {
14 if (SplitJidResource(jid
, &bare_jid
, &resource
)) {
15 return base::StringToLowerASCII(bare_jid
) + "/" + resource
;
17 return base::StringToLowerASCII(bare_jid
);
20 bool SplitJidResource(const std::string
& full_jid
,
21 std::string
* bare_jid
,
22 std::string
* resource
) {
23 size_t slash_index
= full_jid
.find('/');
24 if (slash_index
== std::string::npos
) {
35 *bare_jid
= full_jid
.substr(0, slash_index
);
38 *resource
= full_jid
.substr(slash_index
+ 1);
43 } // namespace remoting