use regex + static method to centralize hashedfavicon URL behavior
This commit is contained in:
@ -1,13 +1,11 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
const TimeTracker = require('./time')
|
||||
const Server = require('./server')
|
||||
|
||||
const config = require('../config')
|
||||
const minecraftVersions = require('../minecraft_versions')
|
||||
|
||||
const HASHED_FAVICON_URL = '/hashedfavicon_'
|
||||
const HASHED_FAVICON_EXTENSION = '.png'
|
||||
|
||||
class ServerRegistration {
|
||||
serverId
|
||||
lastFavicon
|
||||
@ -233,16 +231,18 @@ class ServerRegistration {
|
||||
if (!this._faviconHasher) {
|
||||
this._faviconHasher = crypto.createHash('md5')
|
||||
}
|
||||
|
||||
this.faviconHash = this._faviconHasher.update(favicon).digest('hex').toString()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
getFaviconUrl () {
|
||||
if (this.faviconHash) {
|
||||
return HASHED_FAVICON_URL + this.faviconHash + HASHED_FAVICON_EXTENSION
|
||||
return Server.getHashedFaviconUrl(this.faviconHash)
|
||||
} else if (this.data.favicon) {
|
||||
return this.data.favicon
|
||||
}
|
||||
|
Reference in New Issue
Block a user