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 redis = require('redis')
|
||||||
const startOfDay = require('date-fns/start_of_day')
|
const startOfDay = require('date-fns/start_of_day')
|
||||||
const addDays = require('date-fns/add_days')
|
const addDays = require('date-fns/add_days')
|
||||||
|
const {
|
||||||
|
parsePackageURL
|
||||||
|
} = require('./middleware/PackageUtils')
|
||||||
const {
|
const {
|
||||||
createDayKey,
|
createDayKey,
|
||||||
createHourKey
|
createHourKey
|
||||||
|
@ -71,12 +74,9 @@ const toSeconds = (millis) =>
|
||||||
const stringifySeconds = (seconds) =>
|
const stringifySeconds = (seconds) =>
|
||||||
new Date(seconds * 1000).toISOString()
|
new Date(seconds * 1000).toISOString()
|
||||||
|
|
||||||
// TODO: Copied from express-unpkg, use the same function
|
|
||||||
const URLFormat = /^\/((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(\/.*)?$/
|
|
||||||
|
|
||||||
const getPackageName = (pathname) => {
|
const getPackageName = (pathname) => {
|
||||||
const match = URLFormat.exec(pathname)
|
const parsed = parsePackageURL(pathname)
|
||||||
return match && match[1]
|
return parsed && parsed.packageName
|
||||||
}
|
}
|
||||||
|
|
||||||
const oneSecond = 1000
|
const oneSecond = 1000
|
||||||
|
|
Loading…
Reference in New Issue