-
Notifications
You must be signed in to change notification settings - Fork 209
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
loosen page name validation to allow page names to end in dates #1155
Comments
I also have no idea why is there such a restriction, because I would assume that if a page is named, e.g., Well, I dug into this because I also ran into exactly the same issue. I propose to limit what's an extension by replacing this regex with this one Edit: We should utilize mime types for this. I do not really see any other way to workarround. Let SB assume that everything is Markdown except file extensions enumerated in the configuration (with some sensible defaults perhaps hardcoded or registered by plugs). Example: mime:
application/postscript:
- ps
- eps
application/pdf:
- pdf We could then even consider some "mailcap"-like support in SB for the recognized mime types, so that one could specify what to do when such file is referenced, such as that referenced PDF file ( mailcap:
application/pdf: embed Like this etc.
What do you think? Isn't it be a general solution to the issue? @zefhemel @stapelberg ? |
To serve files with the correct MIME type, Go implements content-type sniffing, see https://pkg.go.dev/net/http#DetectContentType (click on the function name to see the implementation — the longest part are the various file signatures) — maybe such an approach would be available to silverbullet, too, making any sort of configuration unnecessary? I don’t really understand what MIME types have to do with the restriction on page names, though? Can you explain the connection please? |
I would like to raise some more attention to this issue, please. I started to document some large project in SB and I cannot have pages with hostnames and IPv4 addresses as names. I do not see any sensible workarround so I would like to beg for this issue to be resolved somehow (to at least allow the dots). Thank you. My personal (strong) opinion on this is that there should be simply no restrictions at all. The resolution of this issue should at least allow |
I've found this line of code is the issue. Would changing the /\.[a-zA-Z0-9]+$/.test(name) to /\.md$/.test(name) as a quick and dirty fix do any harm? @zefhemel The chance that somebody would like to name a page with trailing I have also no idea why there is the leading dot restriction. Such page will just appear as "hidden" on unices. That's no harm at all. Or would it make any harm to anything if this rule was relaxed too? @zefhemel 😀 I would really like to know why there are so many restrictive rules in naming things everywhere. What is the exact reasoning behind these restrictions? @zefhemel |
Thinking about it more further, to allow URL-specific characters such as |
The validatePageName function prevents me from ending my page names with a date.
For example, I placed a file called “notes 14.11.2024.md” in my space.
I can link this page no problem:
But actually opening the page results in a 404:
Using cmd+k, I can see the page, but opening it by pressing Enter results in an error toast:
It would be good to make the name validation more consistent, but more importantly, I would suggest to loosen or entirely remove name validation.
I can’t find an explanation of what the validation is good for. What’s wrong with using page names that end in file extensions?
And even if validation must be kept for some reason, I think the special case of using a date as part of a page name should be considered reasonable enough to be added as a special case.
The text was updated successfully, but these errors were encountered: