diff --git a/routers/web/repo/resource.go b/routers/web/repo/resource.go index 2499cc0d04..bcf7f76595 100644 --- a/routers/web/repo/resource.go +++ b/routers/web/repo/resource.go @@ -41,28 +41,30 @@ func GetRenderedTrustPropsWithSearchLinks(ctx *context.Context, repo interface{} } trustPropNamesMatches := regExp.FindAllStringSubmatch(trustProps, -1) - if trustPropNamesMatches == nil { - return "", err - } - var trustPropsWithSafeURLs = strings.Clone(trustProps) - var trustPropName string - var searchQS string + var transformedTrustProps string + if trustPropNamesMatches == nil { + transformedTrustProps = trustProps + } else { + transformedTrustProps = strings.Clone(trustProps) + var trustPropName string + var searchQS string - for _, trustPropNameMatches := range trustPropNamesMatches { - trustPropName = trustPropNameMatches[1] - searchQS = strings.ReplaceAll(trustPropName, " ", "+") - trustPropSubstitutionPattern := fmt.Sprintf( - `- [ ] %s [найти](/explore/%s?tab=&q=%s)`, - trustPropName, - strings.ToLower(fieldName), - searchQS) + for _, curTrustPropNameMatches := range trustPropNamesMatches { + trustPropName = curTrustPropNameMatches[1] + searchQS = strings.ReplaceAll(trustPropName, " ", "+") + trustPropSubstitutionPattern := fmt.Sprintf( + `- [ ] %s [найти](/explore/%s?tab=&q=%s)`, + trustPropName, + strings.ToLower(fieldName), + searchQS) - trustPropsWithSafeURLs = strings.Replace(trustPropsWithSafeURLs, trustPropNameMatches[0], trustPropSubstitutionPattern, -1) + transformedTrustProps = strings.Replace(transformedTrustProps, curTrustPropNameMatches[0], trustPropSubstitutionPattern, -1) + } } var renderedTrustPropsWithSafeURLs string - renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, trustPropsWithSafeURLs) + renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, transformedTrustProps) renderedTrustPropsWithTargetBlank := strings.ReplaceAll(renderedTrustPropsWithSafeURLs, "