mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed disabling search via config
fixes https://github.com/TryGhost/Ghost/issues/16120 - if you set `sodoSearch.url` to `false` in config, it'll currently crash because we're not correctly handling the types correctly - the first part of the fix is ensuring the value is a string so we can call `.includes` on it - second, the `false` value is passed into the output as a string, so we should detect if we passed a false value and early return with an empty string if so - credits to https://github.com/ltoinel for the fix inspiration
This commit is contained in:
parent
b8d071e223
commit
55b7bef9ad
2 changed files with 7 additions and 2 deletions
|
@ -76,6 +76,11 @@ function getMembersHelper(data, frontendKey) {
|
|||
function getSearchHelper(frontendKey) {
|
||||
const adminUrl = urlUtils.getAdminUrl() || urlUtils.getSiteUrl();
|
||||
const {scriptUrl, stylesUrl} = getFrontendAppConfig('sodoSearch');
|
||||
|
||||
if (!scriptUrl) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const attrs = {
|
||||
key: frontendKey,
|
||||
styles: stylesUrl,
|
||||
|
|
|
@ -4,10 +4,10 @@ function getFrontendAppConfig(app) {
|
|||
const appVersion = config.get(`${app}:version`);
|
||||
let scriptUrl = config.get(`${app}:url`);
|
||||
let stylesUrl = config.get(`${app}:styles`);
|
||||
if (scriptUrl.includes('{version}')) {
|
||||
if (typeof scriptUrl === 'string' && scriptUrl.includes('{version}')) {
|
||||
scriptUrl = scriptUrl.replace('{version}', appVersion);
|
||||
}
|
||||
if (stylesUrl?.includes('{version}')) {
|
||||
if (typeof stylesUrl === 'string' && stylesUrl?.includes('{version}')) {
|
||||
stylesUrl = stylesUrl.replace('{version}', appVersion);
|
||||
}
|
||||
return {
|
||||
|
|
Loading…
Add table
Reference in a new issue