Skip to content

Commit

Permalink
Add '/pbl/*' as a valid URL
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrozadotdev committed Feb 6, 2024
1 parent 1e4db9b commit 61b9234
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export function BrandingSettings() {
}
placeholder={trans("branding.logoPlaceholder")}
checkRule={{
check: (value) => !value || checkUrlValid(value),
check: (value) => !value || checkUrlValid(value) || value.startsWith("/pbl/"),
errorMsg: trans("branding.urlCheck"),
}}
/>
Expand Down Expand Up @@ -270,7 +270,7 @@ export function BrandingSettings() {
}
placeholder={trans("branding.faviconPlaceholder")}
checkRule={{
check: (value) => !value || checkUrlValid(value),
check: (value) => !value || checkUrlValid(value) || value.startsWith("/pbl/"),
errorMsg: trans("branding.urlCheck"),
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function CreateModal(props: CreateModalProp) {
}
placeholder={trans("idSource.customIconUrlPlaceholder")}
checkRule={{
check: (value) => !value || checkUrlValid(value),
check: (value) => !value || checkUrlValid(value) || value.startsWith("/pbl/"),
errorMsg: trans("idSource.customIconUrlCheckMsg"),
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion client/packages/openblocks/src/util/stringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const COLOR_PALETTE = [

export const PHONE_NUMBER_PATTERN = /^1\d{10}$/;
export const EMAIL_PATTERN = /^[\w-+.]+@([\w-]+\.)+[\w-]{2,}$/;
export const URL_PATTERN = /^(https?:\/\/)?([\w-])+\.{1}([a-zA-Z]{2,63})([/\w-]*)*\/?\??([^#\n\r]*)?#?([^\n\r]*)$/; // prettier-ignore
export const URL_PATTERN = /^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$/; // prettier-ignore
export const HEXCOLOR_PATTERN =/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;

export const checkOtpValid = (value: string): boolean => {
Expand Down
7 changes: 4 additions & 3 deletions server/models/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import (
"encoding/json"
"strings"
"sync"

validation "github.com/go-ozzo/ozzo-validation/v4"
Expand Down Expand Up @@ -38,8 +39,8 @@ func (s *Settings) Validate(validateHomePageAppSlug ...validation.Rule) error {

return validation.ValidateStruct(s,
validation.Field(&s.Name, validation.Required),
validation.Field(&s.LogoUrl, is.URL),
validation.Field(&s.IconUrl, is.URL),
validation.Field(&s.LogoUrl, validation.When(strings.HasPrefix(s.LogoUrl, "/pbl/")).Else(is.URL)),
validation.Field(&s.IconUrl, validation.When(strings.HasPrefix(s.IconUrl, "/pbl/")).Else(is.URL)),
validation.Field(&s.HeaderColor, is.HexColor),
validation.Field(&s.HomePageAppSlug, validateHomePageAppSlug...),
validation.Field(&s.Themes, is.JSON),
Expand Down Expand Up @@ -207,6 +208,6 @@ type OauthAuth struct {
// Validate makes OauthAuth validatable by implementing [validation.Validatable] interface.
func (a *OauthAuth) Validate() error {
return validation.ValidateStruct(&a,
validation.Field(&a.CustomIconUrl, is.URL),
validation.Field(&a.CustomIconUrl, validation.When(strings.HasPrefix(a.CustomIconUrl, "/pbl/")).Else(is.URL)),
)
}

0 comments on commit 61b9234

Please sign in to comment.