redhat-developer / redhat-developer/yaml-language-server
Make it possible to use file:// prefix with relatives paths
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 352
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 11
Description
Is your enhancement related to a problem? Please describe.
I currently work with a jsonschema which has this reference inside:
{
"$ref": "charts/bitnami/wildfly/charts/common/values.schema.json#",
},
which is currently compatible with yaml-language-server. But it's not with gojsonschema (see here https://github.com/xeipuuv/gojsonschema/blob/b076d39a02e5015af0a2a96636e4cc479ecd9f45/jsonLoader.go#L148C2-L148C2) which is for example used by helm (https://github.com/helm/helm/blob/main/go.mod#L35). So if I want my editor (vscode or/and neovim) to work with yaml-language-server I could keep it like this. But if I also want this to work with helm lint (often used in CI), the checks will fail.
Describe the solution you would like
Not the full solution of cause, but the first thing that probably needs to be adjusted is the regular expression here https://github.com/redhat-developer/yaml-language-server/blob/3a74bdc22a1ae8a752e89cbf32616eacae163cea/src/languageservice/utils/paths.ts#L6C13-L6C13
export const isRelativePath = (path: string): boolean => {
const relativePathRegex = /^(((\.\.?)|([\w-@. ]+))(\/|\\\\?))*[\w-. ]*\.[\w-]+$/i;
return relativePathRegex.test(path);
};
to this
export const isRelativePath = (path: string): boolean => {
const relativePathRegex = /^(file://)?(((\.\.?)|([\w-@. ]+))(\/|\\\\?))*[\w-. ]*\.[\w-]+$/i;
return relativePathRegex.test(path);
};
Just adding (file://)? to the beginning.
Describe alternatives you have considered
Make a suggestion in the gojsonschema project. But I think it would be easier to fix here.
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/languageservice/utils/paths.ts, where isRelativePath and its regular expression are defined. Check the existing path-matching behavior, add coverage for relative paths with a file:// prefix alongside current relative forms, and confirm the helper accepts the requested references without regressing existing cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100