diff --git a/server/IngestLogsWorker.js b/server/IngestLogsWorker.js index 8065f74..79ae4af 100644 --- a/server/IngestLogsWorker.js +++ b/server/IngestLogsWorker.js @@ -6,6 +6,9 @@ const ndjson = require('ndjson') const redis = require('redis') const startOfDay = require('date-fns/start_of_day') const addDays = require('date-fns/add_days') +const { + parsePackageURL +} = require('./middleware/PackageUtils') const { createDayKey, createHourKey @@ -71,12 +74,9 @@ const toSeconds = (millis) => const stringifySeconds = (seconds) => new Date(seconds * 1000).toISOString() -// TODO: Copied from express-unpkg, use the same function -const URLFormat = /^\/((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(\/.*)?$/ - const getPackageName = (pathname) => { - const match = URLFormat.exec(pathname) - return match && match[1] + const parsed = parsePackageURL(pathname) + return parsed && parsed.packageName } const oneSecond = 1000