Ticket #961 (closed defect: fixed)
baseHref not correctly treated when stripping
| Reported by: | gogo | Owned by: | gogo |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.96 |
| Component: | Xinha Core | Version: | trunk |
| Severity: | major | Keywords: | |
| Cc: |
Description
The <base> tag in html, and thus the baseHref config option are intended to take a full URL to the file. That is, something like http://www.example.com/example.html
However this is not correctly treated when stripping because the basename (filename) is not removed from the baseHref before the replacements are done, thus when using a full URL as a correct base href the stripping does not function.
I propose the following fix to fixRelativeLinks (XinhaCore?.js)
if ( typeof this.config.baseHref != 'undefined' && this.config.baseHref !== null )
{
baseRe = new RegExp( "((href|src|background)=\")(" + this.config.baseHref.replace(/\/[^\/]*$/, '/').replace( Xinha.RE_Specials, '\\$1' ) + ")", 'g' );
}
That is, we remove any basename (filename) portion of the baseHref, leaving the baseHref with a trailing slash.
If the baseHref already has a trailing slash, it wouldn't be touched, so one could set the baseHref to a directory in this manner (I think that some people do this, incorrectly).
Comments on this anybody?
