vue-intergrall-plugins 0.0.172 → 0.0.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -66,7 +66,7 @@ import AnexoMensagem from "./AnexoMensagem"
|
|
|
66
66
|
import InteratividadeBotoes from "./InteratividadeBotoes"
|
|
67
67
|
import { formataTimezoneData } from "../../services/textFormatting"
|
|
68
68
|
import LinkPrevue from "link-prevue"
|
|
69
|
-
|
|
69
|
+
import { getLinkPreview } from "link-preview-js";
|
|
70
70
|
|
|
71
71
|
export default {
|
|
72
72
|
components: { AnexoMensagem, InteratividadeBotoes, LinkPrevue },
|
|
@@ -154,19 +154,19 @@ export default {
|
|
|
154
154
|
this.urlFileName = this.getUrlFileName()
|
|
155
155
|
this.message = this.removeUrlStickerByString(this.urlSticker)
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
if(this.validadeIfExistsUrl()){
|
|
158
|
+
const linkRegex = /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm;
|
|
159
|
+
let link = [];
|
|
160
|
+
link = this.removeTags(this.message).match(linkRegex);
|
|
161
|
+
if(!link || link.length == 0){
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
getLinkPreview(this.removeTags(link[0])).then((data) => {
|
|
165
|
+
if(data.images && data.images.length > 0){
|
|
166
|
+
this.urlSticker = data.images[0];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
170
|
},
|
|
171
171
|
getUrlFileName(){
|
|
172
172
|
let urlRegex = /(?<=\/)[^\/\?#]+(?=[^\/]*$)/;
|
|
@@ -182,12 +182,12 @@ export default {
|
|
|
182
182
|
let url = this.message.match(urlRegex)[1];
|
|
183
183
|
return url;
|
|
184
184
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
validadeIfExistsUrl(){
|
|
186
|
+
if(this.message && this.message.indexOf("https://") !== false && this.message.indexOf("<a") !== false){
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
},
|
|
191
191
|
validadeIfExistsSticker(){
|
|
192
192
|
if(this.message && this.message.indexOf("KSTICKERK https://smarters") === 0){
|
|
193
193
|
return true;
|
|
@@ -234,6 +234,15 @@ export default {
|
|
|
234
234
|
// if(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi.test(msg) && this.link) this.setLinkPreview(msg)
|
|
235
235
|
return msg
|
|
236
236
|
},
|
|
237
|
+
removeTags(str) {
|
|
238
|
+
if ((str===null) || (str==='')){
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
else{
|
|
242
|
+
str = str.toString();
|
|
243
|
+
return str.replace( /(<([^>]+)>)/ig, '');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
237
246
|
// setLinkPreview(link) {
|
|
238
247
|
// try {
|
|
239
248
|
// this.linkPreview = link
|