mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 22:25:28 +00:00
* adds template manager * refactor: checkpoint * centrailized config & template download logic * refactor removed unused code * use global template directory * update related bug fixes * bug fix create cfg dir if missing * fix lint error * bug fix skip writing template dir in callback * misc update * remove unused code * use strings.equalfold for comparison --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
28 lines
813 B
Go
28 lines
813 B
Go
package utils
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
|
|
)
|
|
|
|
const (
|
|
// TemplatesRepoURL is the URL for files in nuclei-templates repository
|
|
TemplatesRepoURL = "https://github.com/projectdiscovery/nuclei-templates/blob/main/"
|
|
)
|
|
|
|
// TemplatePathURL returns the Path and URL for the provided template
|
|
func TemplatePathURL(fullPath string) (string, string) {
|
|
var templateDirectory string
|
|
configData := config.DefaultConfig
|
|
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
|
|
templateDirectory = configData.TemplatesDirectory
|
|
} else {
|
|
return "", ""
|
|
}
|
|
|
|
finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/")
|
|
templateURL := TemplatesRepoURL + finalPath
|
|
return finalPath, templateURL
|
|
}
|