logo

auto_linker

AutoLinker-shim, based on https://git.pleroma.social/pleroma/auto_linker git clone https://hacktivis.me/git/auto_linker.git
commit: 37c5c3bdd1842308f97d21cb93785143d590dcd6
parent db3b14d0f7c50a940c7dc7b50f15da3eab8bfecd
Author: Egor <egor@kislitsyn.com>
Date:   Wed,  3 Apr 2019 08:00:52 +0000

Improve CI

Diffstat:

M.gitlab-ci.yml14+++++++++++---
Mlib/auto_linker/parser.ex2++
Mtest/auto_linker_test.exs4++--
3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml @@ -3,11 +3,13 @@ image: elixir:1.7.2 cache: key: ${CI_COMMIT_REF_SLUG} paths: - - deps - - _build + - deps + - _build + stages: - lint - test + - analysis before_script: - mix local.hex --force @@ -22,5 +24,11 @@ lint: unit-testing: stage: test + coverage: '/(\d+\.\d+\%) \| Total/' + script: + - mix test --trace --cover + +analysis: + stage: analysis script: - - mix test --trace + - mix credo --strict diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex @@ -39,9 +39,11 @@ defmodule AutoLinker.Parser do # @user # @user@example.com + # credo:disable-for-next-line @match_mention ~r/^@[a-zA-Z\d_-]+@[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*|@[a-zA-Z\d_-]+/u # https://www.w3.org/TR/html5/forms.html#valid-e-mail-address + # credo:disable-for-next-line @match_email ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/u @match_hashtag ~r/^(?<tag>\#[[:word:]_]*[[:alpha:]_·][[:word:]_·]*)/u diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs @@ -24,8 +24,8 @@ defmodule AutoLinkerTest do test "phone number and markdown link" do assert AutoLinker.link("888 888-8888 [ab](a.com)", phone: true, markdown: true) == - "<a href=\"#\" class=\"phone-number\" data-phone=\"8888888888\">888 888-8888</a>" <> - " <a href='a.com' class=\"auto-linker\" target=\"_blank\" rel=\"noopener noreferrer\">ab</a>" + ~s(<a href="#" class="phone-number" data-phone="8888888888">888 888-8888</a>) <> + ~s( <a href='a.com' class="auto-linker" target="_blank" rel="noopener noreferrer">ab</a>) end test "all kinds of links" do