Use same URL parsing function for log processing
This commit is contained in:
parent
6b3b279ca3
commit
5c4da640c8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue