You are not logged in.
Pages: 1
I had the problem that the baseHref replacement was also replacing inline text. So if I have the following html snippet:
<a href="http://www.example.com/test">http://www.example.com/test</a>
After opening and saving this content in Xinha it got converted to:
<a href="/test">/test</a>
When really it should be:
<a href="/test">http://www.example.com/test</a>
ie the replacement was occurring on ALL matches in the content, not just those that are actually URLs.
I altered this by changing the following code in the fixRelativeLinks function:
var baseRe = null
if(typeof this.config.baseHref != 'undefined' && this.config.baseHref != null)
{
baseRe = new RegExp(this.config.baseHref.replace(HTMLArea.RE_Specials, '\\$1'), 'g');
}
else
{
baseRe = new RegExp(document.location.href.replace(/([^\/]*\/?)$/, '').replace(HTMLArea.RE_Specials, '\\$1'), 'g');
}
html = html.replace(baseRe, '');
to:
var baseRe = null
if(typeof this.config.baseHref != 'undefined' && this.config.baseHref != null)
{
baseRe = new RegExp("((href|src|background)=[\'\"])(" + this.config.baseHref.replace(HTMLArea.RE_Specials, '\\$1') + ")", 'g');
}
else
{
baseRe = new RegExp("((href|src|background)=[\'\"])(" + document.location.href.replace(/([^\/]*\/?)$/, '').replace(HTMLArea.RE_Specials, '\\$1') + ")", 'g');
}
html = html.replace(baseRe, '$1');
This is not a thorougly tested change and I don't know if this is something useful for others, but I thought I'd post it here anyway.
Offline
Usefull for me
Offline
I have filed this as Ticket #870
Offline
Pages: 1