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

fix: set proper document source if legacy parsed result is given #1040

Merged
merged 2 commits into from
Mar 30, 2020

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Mar 29, 2020

Needed by Studio 😁
A tiny bug, shouldn't really affect anyone besides Studio.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added the t/bug Something isn't working label Mar 29, 2020
@P0lip P0lip requested a review from nulltoken March 29, 2020 15:09
@P0lip P0lip self-assigned this Mar 29, 2020
Copy link
Contributor

@billiegoose billiegoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea if this is correct, but approving because it DMB (doesn't mine bitcoins).

@@ -72,7 +72,7 @@ export class Spectral {
opts.resolve?.documentUri,
);

if (document.source === void 0 && opts.resolve?.documentUri !== void 0) {
if (document.source === null && opts.resolve?.documentUri !== void 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@P0lip That changes looks strange, unrelated to the gist of this PR.

Considering the code of normalizeSource() is

const normalizeSource = (source: Optional<string>): string | null => {
  if (source === void 0) return null;
  return source && !startsWithProtocol(source) ? normalize(source) : source;
};

I wonder, are we also fixing an existing bug? Shouldn't this deserve a slight test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So actually it's not a bug. The typings are correct, but for whatever reason ts didn't complain about it.
Source can either be null or string, not undefined, so the condition was simply wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typings are correct, but for whatever reason ts didn't complain about it.

Weird... 👍

@P0lip P0lip merged commit 9fcf27d into develop Mar 30, 2020
@P0lip P0lip deleted the fix/legacy-doc branch April 2, 2020 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants