Skip to content

Commit

Permalink
fix(go): match go-source by go module prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwind committed Aug 6, 2020
1 parent bdee0ce commit 8783d49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/datasource/go/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ async function getDatasource(goModule: string): Promise<DataSource | null> {
const pkgUrl = `https://${goModule}?go-get=1`;
const res = (await http.get(pkgUrl)).body;
const sourceMatch = regEx(
`<meta\\s+name="go-source"\\s+content="${goModule}\\s+([^\\s]+)`
`<meta\\s+name="go-source"\\s+content="([^\\s]+)\\s+([^\\s]+)`
).exec(res);
if (sourceMatch) {
const [, goSourceUrl] = sourceMatch;
const [, prefix, goSourceUrl] = sourceMatch;
if (!goModule.startsWith(prefix)) {
logger.trace({ goModule }, 'go-source header prefix not match');
return null;
}
logger.debug({ goModule, goSourceUrl }, 'Go lookup source url');
if (goSourceUrl?.startsWith('https://github.com/')) {
return {
Expand Down

0 comments on commit 8783d49

Please sign in to comment.