8000 fix: Normalize name and version correctly by varungandhi-src · Pull Request #99 · sourcegraph/scip-python · GitHub
[go: up one dir, main page]

Skip to content

fix: Normalize name and version correctly #99

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

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Normalize name and version correctly
  • Loading branch information
varungandhi-src committed Sep 7, 2023
commit f035b39eb5efb3318165161dd4f4629142b85302
15 changes: 13 additions & 2 deletions packages/pyright-scip/src/ScipSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ export class ScipSymbol extends TypescriptScipSymbol {
}

public static override package(name: string, version: string): TypescriptScipSymbol {
name = name.replace(/\./, '/');
name = name.trim();
name = normalizeNameOrVersion(name);
version = normalizeNameOrVersion(version);

// @ts-ignore
return new TypescriptScipSymbol(`scip-python python ${name} ${version} `);
}
}

// See https://github.com/sourcegraph/scip/blob/main/scip.proto#L118-L121
function normalizeNameOrVersion(s: string): string {
if (s === '') {
return '.';
}
if (s.indexOf(' ') === -1) {
return s;
}
return s.replace(/ /g, ' ');
}
0