-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MentionFilter base_url config question #161
Comments
Quickly looking, > base_url = '/~'
"/~"
> login = 'jch'
"jch"
> File.join(base_url, login)
"/~/jch"
> base_url = '~'
"~"
> File.join(base_url, login)
"~/jch" Maybe we stop using |
Hmm, ya irb(main):003:0> URI.join('/~', "jch")
URI::BadURIError: both URI are relative Replacing this with a regular string concatenation irb(main):006:0> File.join("https://foo.com/", "jch")
=> "https://foo.com/jch"
irb(main):007:0> File.join("https://foo.com", "jch")
=> "https://foo.com/jch" We could check whether |
I wrote two tests, now just need to figure out the code... 😓 def test_base_url_tilde_with_slash
body = "<p>Hi, @jch!</p>"
link = "<a href=\"~jch\" class=\"user-mention\">@jch</a>"
assert_equal "<p>Hi, #{link}!</p>",
filter(body, '/~').to_html
end
def test_base_url_tilde_without_slash
body = "<p>Hi, @jch!</p>"
link = "<a href=\"~jch\" class=\"user-mention\">@jch</a>"
assert_equal "<p>Hi, #{link}!</p>",
filter(body, '~').to_html
end |
Conditionally concatenating like @jch mentioned: > login = "jch"
"jch"
> base_url = "https://foo.com/"
"https://foo.com/"
> base_url << "/" unless base_url[-1..-1] =~ /\/|~/
nil
> base_url << login
"https://foo.com/jch"
> base_url = "/"
"/"
> base_url << "/" unless base_url[-1..-1] =~ /\/|~/
nil
> base_url << login
"/jch"
> base_url = "~"
"~"
> base_url << "/" unless base_url[-1..-1] =~ /\/|~/
nil
> base_url << login
"~jch" Should we add more conditions to the |
Hi. I am using
MentionFilter
, and my user lives in www.lvh.me:3000/~jch.If I specified
base_url: '~'
or/~
, it gives mewww.lvh.me:3000/~/jch
instead of
www.lvh.me:3000/~jch
.How to achieve behaviour as mentioned with
MentionFilter
?Currently I replace it by myself:
Thanks!
The text was updated successfully, but these errors were encountered: