yaml-language-server
yaml-language-server copied to clipboard
Make it possible to use file:// prefix with relatives paths
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.