This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
-
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.
Merge pull request #17 from eea/develop
Add getURL helper function
- Loading branch information
Showing
5 changed files
with
35 additions
and
3 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,20 @@ | ||
import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers'; | ||
|
||
import isString from 'lodash/isString'; | ||
import isObject from 'lodash/isObject'; | ||
import isArray from 'lodash/isArray'; | ||
|
||
/** | ||
* Get url | ||
* @method getURL | ||
* @param {object} data | ||
* @returns {string} URL string value. | ||
*/ | ||
export const getURL = (data) => { | ||
let url = data; | ||
if (isObject(data) && !isArray(data) && data['@type'] === 'URL') { | ||
url = data['value'] || data['url'] || data['href'] || ''; | ||
} | ||
if (isString(url) && isInternalURL(url)) return flattenToAppURL(url); | ||
return url; | ||
}; |
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 +1,2 @@ | ||
export * from './Url'; | ||
export * from './Widget'; |