Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / signaling / jid_util.cc
blobca0c9094cf40627c76cb72a080988d882a0f5064
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"
9 namespace remoting {
11 std::string NormalizeJid(const std::string& jid) {
12 std::string bare_jid;
13 std::string resource;
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) {
25 if (bare_jid) {
26 *bare_jid = full_jid;
28 if (resource) {
29 resource->clear();
31 return false;
34 if (bare_jid) {
35 *bare_jid = full_jid.substr(0, slash_index);
37 if (resource) {
38 *resource = full_jid.substr(slash_index + 1);
40 return true;
43 } // namespace remoting