Opened 11 years ago

Closed 10 years ago

#556 closed defect (fixed)

stripBaseHref (for relative link)

Reported by: tzenghuei.ang@… Owned by: gogo
Priority: low Milestone: Version 1.0
Component: Xinha Core Version:
Severity: minor Keywords: relative link
Cc:

Description

this doesn't seems work,
however, i come up a simple replacement :

  if(typeof this.config.stripBaseHref != 'undefined' && this.config.stripBaseHref)
  {
    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');
      html = html.replace(baseRe, '');
    }
    else
    {
      //baseRe = new RegExp(document.location.href.replace(/([^\/]*\/?)$/, '').replace(HTMLArea.RE_Specials, '\\$1'), 'g');
      // fixing base href problem
      var host_name = document.location.host;
      var host_protocol = document.location.protocol;
      var _reg = eval('/href="'+host_protocol+'\\/\\/'+host_name+'/');
      baseRe = new RegExp(_reg);
      html = html.replace(baseRe, 'href="');
    }
  }

Change History (3)

comment:1 Changed 10 years ago by ray

  • Resolution set to fixed
  • Status changed from new to closed

stripBaseHref didn't work without baseHref defined explicitly.

fixed RegExp? in rev [685]

comment:2 Changed 10 years ago by Borys

  • Milestone set to Version 1.0
  • Priority changed from normal to low
  • Resolution fixed deleted
  • Severity changed from normal to minor
  • Status changed from closed to reopened

IMHO it should also apply to <img>, as <img src="/path/img.jpg"> is changed to <img src="http://hostname/path/img.jpg">. (tested on 0.91beta-hotfix2)

comment:3 Changed 10 years ago by Borys

  • Resolution set to fixed
  • Status changed from reopened to closed

Ok, my mistake - it's probably not in zip file yet ;-)
But it's high time to stop stripping the hostname with PHP.

Note: See TracTickets for help on using tickets.