blob: 11df8c07b53863dc159518a47ee5b906bdc7c4f1 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001// Copyright 2011 Google Inc. All rights reserved.
2// Use of this source code is governed by the Apache 2.0
3// license that can be found in the LICENSE file.
4
5package internal
6
7import (
8 "strings"
9)
10
11func parseFullAppID(appid string) (partition, domain, displayID string) {
12 if i := strings.Index(appid, "~"); i != -1 {
13 partition, appid = appid[:i], appid[i+1:]
14 }
15 if i := strings.Index(appid, ":"); i != -1 {
16 domain, appid = appid[:i], appid[i+1:]
17 }
18 return partition, domain, appid
19}
20
21// appID returns "appid" or "domain.com:appid".
22func appID(fullAppID string) string {
23 _, dom, dis := parseFullAppID(fullAppID)
24 if dom != "" {
25 return dom + ":" + dis
26 }
27 return dis
28}