package migration

import (
	"net/url"
	"strings"
)

func graphUserBase(userUPN string) string {
	userUPN = strings.TrimSpace(userUPN)
	if userUPN == "" {
		return "/v1.0/me"
	}
	return "/v1.0/users/" + url.PathEscape(userUPN)
}

func graphMicrosoftURL(userUPN, suffix string) string {
	suffix = strings.TrimSpace(suffix)
	if suffix != "" && !strings.HasPrefix(suffix, "/") {
		suffix = "/" + suffix
	}
	return "https://graph.microsoft.com" + graphUserBase(userUPN) + suffix
}
