shwstppr commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270273527
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,22 @@ export const genericUtilPlugin = {
const regexExp =
/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
return regexExp.test(uuid)
}
+
+ app.config.globalProperties.$toBase64Encoded = function (text) {
+ const base64regex =
/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/
+ if (base64regex.test(text)) {
+ return text
+ }
+ return btoa(unescape(encodeURIComponent(text)))
+ }
+
+ app.config.globalProperties.$toBase64AndURIEncoded = function (text) {
+ const base64regex =
/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/
+ if (base64regex.test(text)) {
Review Comment:
This can be useful when user enters an already base64 encoded string.
Use-case: cloud-init allows passing gzipped content. To pass it ACS API user
will already have a base64 encoded string created with means like,
https://base64.guru/converter/encode/file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]