-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIM-1986] Mim 1986 prepend environments in title (#2827)
* Add a processor for environment prepending in title MIM-1986 * Add functionality to prepend environment into title tag in head (wip) * Minor adjustments to header and title regex * Add logging for testing (in test) * Fetch environment from baseUrl in app config * Fix environment string on baseUrl match * Fetch environment string from app config instead * Minor code refactoring * Use optional chain for app config * Move getting environment string functionality to utils * Add environment string to admin tool applications dashboard and bestbet too
- Loading branch information
1 parent
c879d8b
commit 6c26113
Showing
7 changed files
with
41 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getEnvironmentString } from '/lib/ssb/utils/utils' | ||
|
||
exports.responseProcessor = (req: XP.Request, res: XP.Response) => { | ||
const environment = getEnvironmentString() | ||
|
||
if (environment) { | ||
// Prepend environment to title tag in head for DEV, UTV, TEST, and QA | ||
const headRegex = /<head>([\s\S]*?)<\/head>/ | ||
const titleRegex = /<title>(.*?)<\/title>/ | ||
|
||
res.body = (res.body as string).replace(headRegex, (match, headContent) => { | ||
const modifiedHeadContent = headContent.replace(titleRegex, (match: string, titleText: string) => { | ||
return match.replace(titleText, `${environment}: ${titleText}`) | ||
}) | ||
return match.replace(headContent, modifiedHeadContent) | ||
}) | ||
} | ||
|
||
return res | ||
} |
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