Skip to content
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

JsonRefsOptions location set to relative path containing more than 1 level generates invalid fqURI #189

Open
gilmcquillan opened this issue Mar 6, 2021 · 0 comments

Comments

@gilmcquillan
Copy link

gilmcquillan commented Mar 6, 2021

Notice on https://github.com/whitlockjc/json-refs/blob/master/index.js#L101

function combineURIs (u1, u2) {
  ...
  return (remoteUriTypes.indexOf(combinedDetails.reference) === -1 &&
->          combinedDetails.path.indexOf('../') === 0 ? '../' : '') + URI.serialize(combinedDetails);

combinedDetails.path.indexOf('../') === 0 ? '../' : '' has the effect of changing location values starting with ../../../foobar to ../foobar.

My current work around in node is to prepend the result of process.cwd() + '/' to the location.

const jsonRefsOptions = location => {
    return {
      filter: ['relative', 'remote'],
      loaderOptions: {
        processContent: (res, callback) => {
          callback(null, YAML.load(res.text));
        }
      },
      location: `${process.cwd()}/${location}`,
      includeInvalid: true
    };
  };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant