From 4c634b85ed42d83c7437bbfe882c8c0be417cc59 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sun, 9 Feb 2020 14:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=93=BE=E6=8E=A5=E7=9A=84?= =?UTF-8?q?=E6=AD=A3=E5=88=99=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/libs/custom_regexp.rb | 1 + app/models/live_link.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/libs/custom_regexp.rb b/app/libs/custom_regexp.rb index 2980f2ed2..497c26cae 100644 --- a/app/libs/custom_regexp.rb +++ b/app/libs/custom_regexp.rb @@ -4,4 +4,5 @@ module CustomRegexp LASTNAME = /\A[a-zA-Z0-9\u4e00-\u9fa5]+\z/ NICKNAME = /\A[\u4e00-\u9fa5_a-zA-Z0-9]+\z/ PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/ + URL = /\Ahttps?:\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]\z/ end \ No newline at end of file diff --git a/app/models/live_link.rb b/app/models/live_link.rb index cd6655c30..5dcfaf3d3 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -4,7 +4,7 @@ class LiveLink < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy - validates :url, presence: true + validates :url, presence: true, format: { with: CustomRegexp::URL, message: "必须为网址超链接" } validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } def op_auth?