aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/appengine/internal/app_id.go
blob: 11df8c07b53863dc159518a47ee5b906bdc7c4f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

package internal

import (
	"strings"
)

func parseFullAppID(appid string) (partition, domain, displayID string) {
	if i := strings.Index(appid, "~"); i != -1 {
		partition, appid = appid[:i], appid[i+1:]
	}
	if i := strings.Index(appid, ":"); i != -1 {
		domain, appid = appid[:i], appid[i+1:]
	}
	return partition, domain, appid
}

// appID returns "appid" or "domain.com:appid".
func appID(fullAppID string) string {
	_, dom, dis := parseFullAppID(fullAppID)
	if dom != "" {
		return dom + ":" + dis
	}
	return dis
}