From 3ebfb7a28b4fd98e7a13f43ea26197118a85ef21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Mon, 6 Nov 2023 11:55:29 +0000 Subject: [PATCH] remove IsCustomTemplate func --- pkg/utils/template_path.go | 10 +++++++--- pkg/utils/utils.go | 5 ----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/utils/template_path.go b/pkg/utils/template_path.go index f233b0f2cc..7bbbe14fd1 100644 --- a/pkg/utils/template_path.go +++ b/pkg/utils/template_path.go @@ -13,11 +13,15 @@ const ( // TemplatePathURL returns the Path and URL for the provided template func TemplatePathURL(fullPath, templateId string) (string, string) { - if IsCustomTemplate(fullPath) { + var templateDirectory string + configData := config.DefaultConfig + if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) { + templateDirectory = configData.TemplatesDirectory + } else { return "", "" } - relativePath := strings.TrimPrefix(strings.TrimPrefix(fullPath, config.DefaultConfig.TemplatesDirectory), "/") + finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/") templateURL := TemplatesRepoURL + templateId - return relativePath, templateURL + return finalPath, templateURL } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7aeda7ce0e..87303c9ed1 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -78,8 +78,3 @@ func StringSliceContains(slice []string, item string) bool { } return false } - -// IsCustomTemplate checks if the template is a custom template -func IsCustomTemplate(templatePath string) bool { - return !strings.HasPrefix(templatePath, config.DefaultConfig.TemplatesDirectory) -}