diff --git a/src/libraries/utils.js b/src/libraries/utils.js new file mode 100644 index 00000000..82d26d52 --- /dev/null +++ b/src/libraries/utils.js @@ -0,0 +1,28 @@ +/** + * Verifies whether the url starts with http:// or https:// + * @function + * @param {string} url - The url of the portfolio site + * @returns {boolean} + */ + const isValidUrl = (url) => { + return url.indexOf("https://") === 0 || url.indexOf("http://") === 0 + } + + /** + * Our CMS does not validate urls, + * urls are entered in manually by the author, + * so this is to ensure a valid url to navigate to + * @function + * @param {string} url - The url of the portfolio site + * @returns {string} url - The passed in url or a new url + * with https appended to it + */ + export const validUrl = (url = "") => { + const https = "https://"; + const trimmedUrl = url.trim(); + + if (isValidUrl(trimmedUrl)) { + return trimmedUrl; + } + return https + trimmedUrl; + }; \ No newline at end of file diff --git a/src/pages/About.vue b/src/pages/About.vue index 5f9535cc..187f0bb0 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -47,7 +47,7 @@ site @@ -86,9 +86,21 @@ query diff --git a/src/templates/Biopost.vue b/src/templates/Biopost.vue index 4a26eb65..e4e767d8 100644 --- a/src/templates/Biopost.vue +++ b/src/templates/Biopost.vue @@ -16,13 +16,13 @@ /> Email Portfolio @@ -63,12 +63,21 @@