Skip to content

Commit

Permalink
ホスト名をlowercaseに正規化するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
pirosiki197 committed Oct 21, 2023
1 parent fb31e1d commit 8f9451f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/domain/app_website.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func (w *Website) Validate() error {
return nil
}

func (w *Website) Normalize() {
w.FQDN = strings.ToLower(w.FQDN)
}

func (w *Website) pathComponents() []string {
// NOTE: empty PathPrefix must not exist
if w.PathPrefix == "/" {
Expand Down
6 changes: 6 additions & 0 deletions pkg/usecase/apiserver/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (s *Service) CreateApplication(ctx context.Context, app *domain.Application
}
app.OwnerIDs = repo.OwnerIDs

for _, website := range app.Websites {
website.Normalize()
}
// Validate
err = s.validateApp(ctx, app)
if err != nil {
Expand Down Expand Up @@ -213,6 +216,9 @@ func (s *Service) UpdateApplication(ctx context.Context, id string, args *domain
}
app.Apply(args)

for _, website := range app.Websites {
website.Normalize()
}
// Validate
if err = s.validateApp(ctx, app); err != nil {
return err
Expand Down

0 comments on commit 8f9451f

Please sign in to comment.