weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1269270613
##########
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:
do we need this check ?
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,14 @@ 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
Review Comment:
tested ok. I have some other comments
##########
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) {
Review Comment:
@shwstppr
this looks same as toBase64Encoded ?
--
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]