forked from adobecom/milo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-134968 - [Blog2Milo] Broken links on Homepage (adobecom#1101)
* MWPW-134968 - [Blog2Milo] Broken links on Homepage - introduce a configuration called 'lang-root' in the page metadata - append the lang-root config to the category links * MWPW-134968 - [Blog2Milo] Broken links on Homepage - removing the bulk performance test as it relies on the Helix Admin Service performance * MWPW-134968 - [Blog2Milo] Broken links on Homepage - address PR feedback - move the utility function to its own helpers.js below /libs/utils - rename utility function - error handling for new URL()
- Loading branch information
1 parent
823a845
commit 2d10c51
Showing
5 changed files
with
27 additions
and
92 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getMetadata } from './utils.js'; | ||
|
||
/** | ||
* Prefixes the link with the language root defined in the metadata | ||
* @param link | ||
* @returns {string|*} | ||
*/ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export function updateLinkWithLangRoot(link) { | ||
const langRoot = getMetadata('lang-root'); | ||
if (!langRoot) return link; | ||
try { | ||
const url = new URL(link); | ||
url.pathname = `${langRoot}${url.pathname}`; | ||
return url.href; | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('Could not update link with lang root', e); | ||
return link; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.