-
Notifications
You must be signed in to change notification settings - Fork 369
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
[Feature Request] Add option to include slashes and dots in project name #285
Comments
You are right, it is not possible to use '/' as input in the project name. If the go-blueprint create -n github.com/user/project-name command is executed, the CLI would create subdirectories after '/'. Thanks for addressing this....it needs to be fixed. |
This is an easy fix, the only thing that needs to be changed is the regex in the sanitizeInput() function (textinput.go): func sanitizeInput(input string) error {
matched, err := regexp.Match("^[a-zA-Z0-9_\\-\\./]+$", []byte(input))
if !matched {
return fmt.Errorf("string violates the input regex pattern, err: %v", err)
}
return nil
} |
I rather meant to make dots and slashes available at the same time. To allow urls like github.com/wojcraft/test I embedded screenshot |
I agree...I did just a quick test. |
Wait, I think you don't have to explicitly use a regex because it's a string. |
Dear @Ujstor, So, are you going to implement this feature? I feel a little disoriented looking at this issue, so I'm just asking about a status of it. If you want to know more details about what I mean in this quite small Feature Request, just let me know! All the best! |
The issue is open, and anyone can solve it and submit a PR :) |
Hi @Ujstor If the project name entered is "github.com/wojcraft/project-name", could you please suggest what should be the expected behavior from 1 or 2? Behavior 1: Behavior 2: If behavior 2 is expected, than is it possible on Linux based operating systems to have / in directory name? |
@Patel-Raj Behavior 2 is what you get if we change the sanitizeInput function and allow . and /. In this case, the blueprint’s default behavior will create a directory tree github.com/wojcraft/project-name. As you pointed out, on Windows, this will be a big issue. @H0llyW00dzZ This is why regex is used, not just a plain string. |
It can be more easily achieved using the URL builder from the standard library and removing the scheme (http/https) instead of using regex. for example: func sanitizeInput(input string) error {
// Remove the URL scheme (e.g., http://, https://) from the input
input = strings.TrimPrefix(strings.TrimPrefix(input, "https://"), "http://")
_, err := url.Parse("//" + input)
if err != nil {
return fmt.Errorf("invalid input: %v", err)
}
return nil
} |
And then For non-URL cases, it can be achieved by using regex because if using regex for |
Tell us about your feature request
It's not possible to enter project name as this:
github.com/wojcraft/project-name
- I've got used to this naming for learning and I see it also affects imports. Can you help me with that?Here is screenshot of a input that needs to be modified in order to solve this request
![image](https://private-user-images.githubusercontent.com/141335133/352217831-29c29726-03c4-442f-a2aa-d9ffee1975c4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MzQyODUsIm5iZiI6MTczOTczMzk4NSwicGF0aCI6Ii8xNDEzMzUxMzMvMzUyMjE3ODMxLTI5YzI5NzI2LTAzYzQtNDQyZi1hMmFhLWQ5ZmZlZTE5NzVjNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNlQxOTI2MjVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MGRkNmIyNDhmZGE3MzBiNmY0ZWZiNTYzMDg1YzdkYmI3MDUxNTM0ZjY1YjFkY2ViZTY2YTY4OGMzMDBmYzZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.mz94jMvcbbi4oan2glvO1RZu5c5DibwSPolKPSQgXhA)
Disclaimer
The text was updated successfully, but these errors were encountered: