Enable remote launcher catalog source
This commit is contained in:
@@ -476,7 +476,11 @@ exports.getLibraryCatalogSource = function(){
|
||||
* @param {string|null} source A remote URL or local path.
|
||||
*/
|
||||
exports.setLibraryCatalogSource = function(source){
|
||||
config.library.catalogSource = source
|
||||
if(typeof source !== 'string' || source.trim().length === 0){
|
||||
config.library.catalogSource = null
|
||||
} else {
|
||||
config.library.catalogSource = source.trim()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -998,3 +1002,22 @@ exports.getAllowPrerelease = function(def = false){
|
||||
exports.setAllowPrerelease = function(allowPrerelease){
|
||||
config.settings.launcher.allowPrerelease = allowPrerelease
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a library catalog source.
|
||||
*
|
||||
* @param {string} source A remote URL or local path.
|
||||
* @returns {boolean} Whether the value is allowed.
|
||||
*/
|
||||
exports.validateLibraryCatalogSource = function(source){
|
||||
const trimmedSource = typeof source === 'string' ? source.trim() : ''
|
||||
if(trimmedSource.length === 0){
|
||||
return true
|
||||
}
|
||||
|
||||
if(trimmedSource.includes('://')){
|
||||
return /^https?:\/\/\S+$/i.test(trimmedSource) || trimmedSource.startsWith('file://')
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user