up
This commit is contained in:
+29
-5
@@ -10,8 +10,21 @@ import (
|
||||
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||
)
|
||||
|
||||
// getAppURL devuelve la URL base absoluta (sin slash final).
|
||||
// Si APP_URL es http://localhost sin puerto, añade APP_PORT para enlaces en desarrollo.
|
||||
// GetPublicURL devuelve la URL pública para enlaces en correos, Telegram y webhooks.
|
||||
func GetPublicURL() string {
|
||||
return getPublicURL()
|
||||
}
|
||||
|
||||
// getPublicURL usa APP_PUBLIC_URL si está configurada; si no, APP_URL (con puerto en localhost).
|
||||
func getPublicURL() string {
|
||||
if u := normalizeBaseURL(app.Http.Server.PublicUrl); u != "" {
|
||||
return u
|
||||
}
|
||||
return getAppURL()
|
||||
}
|
||||
|
||||
// getAppURL devuelve la URL base de la app (sin slash final).
|
||||
// Si APP_URL es http://localhost sin puerto, añade APP_PORT para desarrollo local.
|
||||
func getAppURL() string {
|
||||
u := strings.TrimRight(app.Http.Server.Url, "/")
|
||||
if u == "" {
|
||||
@@ -33,10 +46,21 @@ func getAppURL() string {
|
||||
return u
|
||||
}
|
||||
|
||||
// absAppURL convierte una ruta relativa en URL absoluta para correo/Telegram.
|
||||
func normalizeBaseURL(raw string) string {
|
||||
u := strings.TrimSpace(strings.TrimRight(raw, "/"))
|
||||
if u == "" {
|
||||
return ""
|
||||
}
|
||||
if !strings.Contains(u, "://") {
|
||||
u = "https://" + u
|
||||
}
|
||||
return strings.TrimRight(u, "/")
|
||||
}
|
||||
|
||||
// absAppURL convierte una ruta relativa en URL absoluta pública (correo/Telegram).
|
||||
func absAppURL(path string) string {
|
||||
if path == "" {
|
||||
return getAppURL()
|
||||
return getPublicURL()
|
||||
}
|
||||
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
|
||||
return path
|
||||
@@ -44,7 +68,7 @@ func absAppURL(path string) string {
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
return getAppURL() + path
|
||||
return getPublicURL() + path
|
||||
}
|
||||
|
||||
func adminTicketPath(ticketID uint) string {
|
||||
|
||||
Reference in New Issue
Block a user