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

fix(examples): use underscore instead of hyphen #766

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

harry-hov
Copy link
Contributor

const (
reDomainPart = `gno\.land`
rePathPart = `[a-z][a-z0-9_]*`
rePkgName = `^[a-z][a-z0-9_]*$`
rePkgPath = reDomainPart + `/p/` + rePathPart + `(/` + rePathPart + `)*`
reRlmPath = reDomainPart + `/r/` + rePathPart + `(/` + rePathPart + `)*`
rePkgOrRlmPath = `^(` + rePkgPath + `|` + reRlmPath + `)$`
reFileName = `^[a-zA-Z0-9_]*\.[a-z0-9_\.]*$`
)
// path must not contain any dots after the first domain component.
// file names must contain dots.
// NOTE: this is to prevent conflicts with nested paths.
func (mempkg *MemPackage) Validate() error {
ok, _ := regexp.MatchString(rePkgName, mempkg.Name)
if !ok {
return errors.New(fmt.Sprintf("invalid package name %q", mempkg.Name))
}
ok, _ = regexp.MatchString(rePkgOrRlmPath, mempkg.Path)
if !ok {
return errors.New(fmt.Sprintf("invalid package/realm path %q", mempkg.Path))
}
fnames := map[string]struct{}{}
for _, memfile := range mempkg.Files {
ok, _ := regexp.MatchString(reFileName, memfile.Name)
if !ok {
return errors.New(fmt.Sprintf("invalid file name %q", memfile.Name))
}
if _, exists := fnames[memfile.Name]; exists {
return errors.New(fmt.Sprintf("duplicate file name %q", memfile.Name))
}
fnames[memfile.Name] = struct{}{}
}
return nil
}

The regular expression here does not allow -(hyphen) in package or realm path.

Renamed r/demo/releases-example -> r/demo/releases_example

@harry-hov harry-hov requested a review from a team as a code owner April 20, 2023 20:20
@harry-hov harry-hov self-assigned this Apr 20, 2023
Copy link
Contributor

@tbruyelle tbruyelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like go package identifier 👍

@moul moul merged commit 8c92ea3 into gnolang:master Apr 20, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🌟 Wanted for Launch
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants