# Url rewriting

**URL:** <https://www.ruby-forum.com/t/url-rewriting/183628>\
**Category:** Rails\
**Created:** [February 17, 2010, 5:32pm UTC](https://www.ruby-forum.com/t/url-rewriting/183628 "2010-02-17T17:32:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 17, 2010, 5:32pm UTC](https://www.ruby-forum.com/t/url-rewriting/183628/1 "2010-02-17T17:32:24Z")

</div>

I discovered Sanitize gem and it’s pretty good but one thing I can see  
is that if someone puts a URL in the body of text without markup, that  
would become a link that would drive the person who clicks the link  
off-site which I don’t really want.

So if I have say…

@test = “This is a really cool website - [http://www.example.com](http://www.example.com)”

I would want it to be changed to…

@test = “This is a really cool website - [http://www.example.com](http://www.example.com)”

Is there some gem or plugin? Do I have to write some complicated gsub  
routine?

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 17, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/url-rewriting/183628/2 "2010-02-17T21:56:50Z")

</div>

Craig W. wrote:

> I discovered Sanitize gem and it’s pretty good but one thing I can see  
> is that if someone puts a URL in the body of text without markup, that  
> would become a link that would drive the person who clicks the link  
> off-site which I don’t really want.
> 
> So if I have say…
> 
> @test = “This is a really cool website - [http://www.example.com](http://www.example.com)”
> 
> I would want it to be changed to…
> 
> @test = “This is a really cool website - [http://www.example.com](http://www.example.com)”

Probably not a great idea. Don’t force links to open in a new window –  
it’s extremely annoying.

That said, you can do at least some of this with the element.

> Is there some gem or plugin? Do I have to write some complicated gsub  
> routine?
> 
> Craig
> 
> –  
> This message has been scanned for viruses and  
> dangerous content by MailScanner, and is  
> believed to be clean.

When will you stop appending this silly footer to your e-mail?

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
