mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-13 18:45:43 +05:00
Fix invalid profile URL #1974
This commit is contained in:
parent
ba1e72711a
commit
cd515aced3
@ -220,6 +220,9 @@
|
||||
border-top-right-radius: 0px;
|
||||
border-bottom-right-radius: 0px;
|
||||
}
|
||||
input:invalid {
|
||||
border-color: red;
|
||||
}
|
||||
button {
|
||||
border-top-left-radius: 0px;
|
||||
border-bottom-left-radius: 0px;
|
||||
|
||||
@ -150,16 +150,18 @@ define([
|
||||
common.openUnsafeURL(href);
|
||||
});
|
||||
|
||||
APP.$linkEdit = $();
|
||||
};
|
||||
var refreshLink = function (data) {
|
||||
APP.$linkEdit.removeClass('fa-pencil').removeClass('fa');
|
||||
if (!data.url) {
|
||||
APP.$linkEdit.text(Messages.profile_addLink);
|
||||
return void APP.$link.hide();
|
||||
}
|
||||
// Only show valid URLs
|
||||
try {
|
||||
new URL(data.url);
|
||||
} catch (e) {
|
||||
return void APP.$link.hide();
|
||||
}
|
||||
APP.$link.attr('href', data.url).text(data.url).show();
|
||||
APP.$linkEdit.text('').addClass('fa fa-pencil');
|
||||
};
|
||||
|
||||
var addFriendRequest = function ($container) {
|
||||
|
||||
@ -1869,7 +1869,9 @@ define([
|
||||
makeBlock('profile-link', function(cb) {
|
||||
if (!common.isLoggedIn()) { return cb(false); }
|
||||
|
||||
const input = APP.blocks.input();
|
||||
const input = APP.blocks.input({
|
||||
type: 'url'
|
||||
});
|
||||
const button = APP.blocks.button('primary', '',
|
||||
Messages.settings_save);
|
||||
const inputButton = APP.blocks.inputButton(input, button, {
|
||||
@ -1881,7 +1883,8 @@ define([
|
||||
const $input = $(input).val(APP.profileData?.url || '');
|
||||
|
||||
Util.onClickEnter($(button), () => {
|
||||
const value = $(input).val();
|
||||
if ($input.is(':invalid')) { return; }
|
||||
const value = $input.val();
|
||||
APP.profile.execCommand('SET', {
|
||||
key: 'url',
|
||||
value
|
||||
|
||||
Loading…
Reference in New Issue
Block a user