-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1941 from Inist-CNRS/fix/title-tenant-name
Fix tenant name in page title to avoid crash on server side
- Loading branch information
Showing
10 changed files
with
82 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
import { getCleanHost } from '../../../common/uris'; | ||
|
||
export default () => { | ||
const HOST_REGEX = /https?:\/\/([\w-]+)/; | ||
|
||
/** | ||
* @param tenant{string|undefined} | ||
* @param prefix{string|undefined} | ||
* @return {string} | ||
*/ | ||
export default (tenant, prefix) => { | ||
const host = getCleanHost(); | ||
|
||
/** | ||
* @type {string} | ||
* @type {string[]} | ||
*/ | ||
const tenant = window.__TENANT__ ?? 'default'; | ||
const title = []; | ||
|
||
if (prefix) { | ||
title.push(prefix); | ||
} | ||
|
||
if (tenant) { | ||
title.push(tenant); | ||
} | ||
|
||
if (host) { | ||
title.push(HOST_REGEX.exec(host)[1]); | ||
} | ||
|
||
return host | ||
? `${tenant} - ${/https?:\/\/([\w-]+)/.exec(host)[1]}` | ||
: `${tenant} - example`; | ||
return title.join(' - '); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters