-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
favicon prefixes href with leading slash (/
) when url is absolute
#2647
Comments
\
) when url is absolute/
) when url is absolute
@techfg, Thank you for your report!👍 I have spent couple days trying to understand the codebase of starlight, especially around the schemas. After all the experiments, I made a PR that fixes this issue↓ Best Regards, |
Hi @SnowDingo - Thanks for reviewing this and I agree, I believe the 2nd option is likely best since favicon can be absolute or relative url and therefore I feel Starlight should support both. Unfortunately, in taking a look at the #2651, it appears that if the url starts with Would recommend to wait to hear from a maintainer on which approach they would like Starlight to take on this one and once decided, possibly you could adjust the PR you submitted based on their feedback. Thanks! |
Dear @techfg. Best Regards, |
Hi @SnowDingo - Yes, agreed, not sure which option here is best and why I think waiting for a maintainer to provide input & a decision makes sense before doing any future work on a potential PR. The decision may be to leave things as-is, implement option 1 (require a relative url only and enforce in schema validation) or option 2 (allow absolute & relative and handle the
Regarding where in the code the |
Thank you for your idea @techfg! I've made changes to the base.ts code as the following and it seems to be working for both absolute and relative URL: /** Get the a root-relative file URL path with the site’s `base` prefixed. */
export function fileWithBase(path: string) {
path = stripLeadingSlash(path);
return path ? base + '' + path : base;
} |
Yes, as mentioned, I would strongly encourage you to wait on any further PR updates until a maintainer has provided guidance on how absolute URLs should be handled. Once a decision is made, if its determined to support absolute urls for favicon, the approach you shared will likely break all areas of the current code base that rely on As I mentioned in prior comment, I think the best way to support absolute URLs would be to modify this code to not call |
Ok. @techfg, I will make another PR that accepts absolute URLs. // A util function to determine if the path is relative or not.
export function absorrelative(path:string){
if (/^https?:\/\//.test(path)) {
return path;
}else{
// Relative URL
return fileWithBase(path);
}
} This code didn't work, so I experimented a bit with the function itself. (i.g adding if true to the if statements and changing some of the fileBase methods to the util function I just created. As a result, I discovered that the fileWithBase function is called somewhere no matter the context of the if statement in the base.ts file, and that part of the code adds the unnecessary slash. |
Hello @SnowDingo - I appreciate your enthusiasm to provide a PR with a fix 😄 However, we still do not know what the starlight maintainers believe the expected behavior should be. Also, feedback on code/approach is better to have within a PR and not in an issue like what is occurring in this issue in recent comments because it takes the focus away from what the issue is and what the expected behavior should be. As mentioned, I'd strongly encourage you to hold off on any further work until we hear from the maintainers on what the expected behavior should be:
Once they provide that input, if you update the PR you've submitted to align with the expected behavior, I'd be happy to provide input in the PR itself on how to correct any issues you may be having. For now, let's avoid any discussion on the code itself in this issue. Thanks! |
Thanks for the update @SnowDingo! @delucis - For when you have the time to review this issue, I think what your suggesting is to keep it relaxed meaning to allow relative or absolute, correct? Assuming yes (which would be recommendation FWIW), then there would be a fix needed to ensure that when absolute, |
What version of
starlight
are you using?0.29.2
What version of
astro
are you using?4.16.10
What package manager are you using?
npm
What operating system are you using?
linux
What browser are you using?
chrome
Describe the Bug
When favicon configuration parameter contains an absolute url, the generated link in head contains a leading slash.
Absolute URLs are valid for favicon so I believe one of the following should be applied:
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-starlight-15r2cj
Participation
The text was updated successfully, but these errors were encountered: