diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 0b584c669cebb2df78eada26c598ca2bbac3d1dc..70e99520d1de75a879acbc982bfd0ba45b8cfd20 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -79,7 +79,7 @@ export async function validateConfig( try { let res = handlebars.compile(val)(config); res = handlebars.compile(res)(config); - res = handlebars.compile(res)(config); + handlebars.compile(res)(config); } catch (err) { errors.push({ depName: 'Configuration Error', diff --git a/lib/datasource/npm/get.ts b/lib/datasource/npm/get.ts index c477ac4dedf76b2f3de3e99781bbf99a187ee775..cf077281fbfded072641c0992946bb229a90997c 100644 --- a/lib/datasource/npm/get.ts +++ b/lib/datasource/npm/get.ts @@ -93,10 +93,9 @@ export async function getDependency( headers.authorization = `Bearer ${process.env.NPM_TOKEN}`; } - if ( - pkgUrl.startsWith('https://registry.npmjs.org') && - !pkgUrl.startsWith('https://registry.npmjs.org/@') - ) { + const uri = url.parse(pkgUrl); + + if (uri.host === 'registry.npmjs.org' && !uri.pathname.startsWith('/@')) { // Delete the authorization header for non-scoped public packages to improve http caching // Otherwise, authenticated requests are not cacheable until the registry adds "public" to Cache-Control // Ref: https://greenbytes.de/tech/webdav/rfc7234.html#caching.authenticated.responses @@ -231,7 +230,7 @@ export async function getDependency( }); return null; } - if (regUrl.startsWith('https://registry.npmjs.org')) { + if (uri.host === 'registry.npmjs.org') { // istanbul ignore if if ( (err.name === 'ParseError' || err.code === 'ECONNRESET') && diff --git a/lib/manager/homebrew/extract.ts b/lib/manager/homebrew/extract.ts index 7e2edf2d72fefa5babf9350275cce932ac40b180..88583b4f714a1b0b9ec2230a6bb342d25c0a2527 100644 --- a/lib/manager/homebrew/extract.ts +++ b/lib/manager/homebrew/extract.ts @@ -14,8 +14,7 @@ function parseSha256(idx: number, content: string): string | null { return null; } i += 1; - let j = i; - j = skip(i, content, c => { + const j = skip(i, content, c => { return c !== '"' && c !== "'"; }); const sha256 = content.slice(i, j); @@ -42,8 +41,7 @@ function parseUrl(idx: number, content: string): string | null { return null; } i += 1; - let j = i; - j = skip(i, content, c => { + const j = skip(i, content, c => { return c !== '"' && c !== "'" && !isSpace(c); }); const url = content.slice(i, j); diff --git a/lib/manager/homebrew/update.ts b/lib/manager/homebrew/update.ts index 5c63b8afb2b2250c61207b885efbd0a5c546b3d8..39bb54ea9786c0be3c7970319c59c36f837ec40d 100644 --- a/lib/manager/homebrew/update.ts +++ b/lib/manager/homebrew/update.ts @@ -142,7 +142,6 @@ export async function updateDependency({ /* 1. Update url field 2. Update sha256 field */ - let newContent = fileContent; let newUrl: string; // Example urls: // "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz" @@ -154,7 +153,7 @@ export async function updateDependency({ ); return fileContent; } - let newSha256; + let newSha256: string; try { newUrl = `https://github.com/${upgrade.managerData.ownerName}/${ upgrade.managerData.repoName @@ -195,7 +194,7 @@ export async function updateDependency({ logger.debug(`Failed to update url for dependency ${upgrade.depName}`); return fileContent; } - newContent = updateUrl(fileContent, upgrade.managerData.url, newUrl); + let newContent = updateUrl(fileContent, upgrade.managerData.url, newUrl); if (!newContent) { logger.debug(`Failed to update url for dependency ${upgrade.depName}`); return fileContent; diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 895545f37047686697003da3b25be9e83fd14703..cfbcc1f2f3f65dfb1bc311986a7a2175cba31735 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -252,7 +252,7 @@ export async function initRepo({ hostType: PLATFORM_TYPE_GITHUB, url: defaults.endpoint, }); - config.isGhe = !defaults.endpoint.startsWith('https://api.github.com'); + config.isGhe = URL.parse(defaults.endpoint).host !== 'api.github.com'; config.renovateUsername = renovateUsername; config.localDir = localDir; config.repository = repository; diff --git a/lib/versioning/ruby/range.ts b/lib/versioning/ruby/range.ts index a7923b66d2dbc9d4ffddbabc638bc1a1d35b3424..be31b163aa2b9bd93e539fff10c84a485f649337 100644 --- a/lib/versioning/ruby/range.ts +++ b/lib/versioning/ruby/range.ts @@ -10,7 +10,7 @@ export interface Range { } const parse = (range: string): Range => { - const regExp = /^(?<operator>[^\d\s]+)?(?<delimiter>\s*)(?<version>[0-9a-zA-Z-.-]+)$/; + const regExp = /^(?<operator>[^\d\s]+)?(?<delimiter>\s*)(?<version>[0-9a-zA-Z-.]+)$/; const value = (range || '').trim(); diff --git a/lib/workers/branch/get-updated.ts b/lib/workers/branch/get-updated.ts index 3cb3c37b9763e49234523f4e738a85bc70828088..6b9bc43999b89e1aad636a5e22b3949bdf6274e5 100644 --- a/lib/workers/branch/get-updated.ts +++ b/lib/workers/branch/get-updated.ts @@ -65,9 +65,8 @@ export async function getUpdatedPackageFiles( logger.error('Could not autoReplace'); throw new Error(WORKER_FILE_UPDATE_FAILED); } - let newContent = existingContent; const updateDependency = get(manager, 'updateDependency'); - newContent = await updateDependency({ + const newContent = await updateDependency({ fileContent: existingContent, upgrade, }); diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index a595ff127eed78c02164c41e510dbe32a4d4b304..32b19a72c2b829b3f51ec05f10e2af32b82516d3 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -74,7 +74,7 @@ export async function getChangeLogJSON({ }); if (!config.token) { // istanbul ignore if - if (sourceUrl.includes('github.com')) { + if (URL.parse(sourceUrl).host.endsWith('github.com')) { logger.warn( { manager, depName, sourceUrl }, 'No github.com token has been configured. Skipping release notes retrieval'