Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use underline for app_code #3335

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bcs-services/bcs-bscp/pkg/config/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"fmt"
"net/url"
"path"
"strings"
)

// HostConf host conf
Expand Down Expand Up @@ -54,6 +55,9 @@ func (c *FrontendConf) initResBaseJSURL(appCode string) error {
return fmt.Errorf("initResBaseJSURL: app_code is required")
}

// 规范: 统一使用下划线做目录名
appCode = strings.ReplaceAll(appCode, "-", "_")

u, err := url.Parse(c.Host.BKSharedResURL)
if err != nil {
return err
Expand Down
31 changes: 31 additions & 0 deletions bcs-services/bcs-bscp/pkg/config/frontend_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

package config

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestInitResBaseJSURL(t *testing.T) {
conf := defaultUIConf()
err := conf.initResBaseJSURL("bk-bscp")
assert.NoError(t, err)
assert.Equal(t, "", conf.Host.BKSharedResBaseJSURL)

conf.Host.BKSharedResURL = "http://repo.test.com"
err = conf.initResBaseJSURL("bk-bscp")
assert.NoError(t, err)
assert.Equal(t, "http://repo.test.com/bk_bscp/base.js", conf.Host.BKSharedResBaseJSURL)
}
Loading