在点击保存的时候,处理url
dealRequestUrl(data) {
const url = data.requestUrl && data.requestUrl.toLowerCase()
const rgExp = /(?<=http|https):///,
isMatch = rgExp.test(url)
if (isMatch) {
let str = ''
const arr = data.requestUrl.split(/(?<=http|https):///)
if(arr[0] === 'http' || arr[0] === 'https'){
arr.shift()
str = arr.join("://")
}else{
str = url
}
data.requestUrl = data.protocol + '://' + str
return data
}
data.requestUrl = data.protocol + '://' + url
return data
},
在点击编辑的时候,处理由后端返回的url
dealInterfaceData(data) {
const url = data.requestUrl || ''
let str = ''
data.protocol = url.toLowerCase().startsWith('https') ? 'https' : 'http'
if(url.includes('://')){
const arr = url.split(/(?<=http|https):///)
arr.shift()
str = arr.join("://")
}else{
str = url
}
data.requestUrl = str
return data
},