Changeset 1433


Ignore:
Timestamp:
03/28/18 22:13:25 (4 months ago)
Author:
gogo
Message:

#1727 - stop-gap fix for fixRelativeUrls causing a problem with intentionally relative urls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1421 r1433  
    829829 
    830830  /** If true, relative URLs (../) will be made absolute.  
    831    *  When the editor is in different directory depth  
    832    *  as the edited page relative image sources will break the display of your images. 
    833    *  this fixes an issue where Mozilla converts the urls of images and links that are on the same server  
    834    *  to relative ones (../) when dragging them around in the editor (Ticket #448)<br /> 
     831   *  
     832   *  When the editor is in different directory depth as the edited page relative  
     833   *   image sources will break the display of your images. 
     834   *  
     835   *  This fixes an issue where Mozilla converts the urls of images and links that  
     836   *   are on the same server to relative ones (../) when dragging them around in  
     837   *   the editor (Ticket #448)<br /> 
     838   *  
     839   *  Note that setting to true will not expand directly relative paths 
     840   *   "foo/bar.html" will not be changed.  Only parental, self-referential or  
     841   *   semi-absolute paths with parental or self-referential components will be  
     842   *   adjusted, some examples of paths this will affect 
     843   *  
     844   *     "/foo/bar/../foo.html" --> /foo/foo.html 
     845   *     "/foo/./foo.html"      --> /foo/foo.html 
     846   *     "./foo.html"       --> "foo.html" 
     847   *     "../foo.html"      --> "/foo.html" (assuming ../ ends up at the root or lower) 
     848   *  
     849   *  You can also set this to the string 'all' and this will include non-parental 
     850   *   relative urls.  I think this is probably a bad idea as it may cause broken URLS 
     851   *   especially when combined with stripBaseHref or if you feed in such urls in your 
     852   *   html. 
     853   *  
    835854   *  Default: <code>true</code> 
    836    *  @type Boolean 
     855   *  @type Boolean|String 
    837856   */ 
    838857  this.expandRelativeUrl = true; 
    839    
     858     
    840859 /**  We can strip the server part out of URL to make/leave them semi-absolute, reason for this 
    841860   *  is that the browsers will prefix  the server to any relative links to make them absolute,  
     
    68446863      { 
    68456864        if(all_urls[j].match(/=["']([a-z]+:)?\/\//)) continue; // Exclude: '//...' and 'https://' 
     6865        if(! (this.config.expandRelativeUrl == 'all')) 
     6866        { 
     6867          // If there is no parental or self-referential path component 
     6868          if(all_urls[j].match(/=["'][a-z0-9_-]/i))    continue; // Exclude: 'relativedir/foo.html' 
     6869        } 
    68466870        if( 
    68476871             ( !all_urls[j].match(/=["']\//)       ) // Starts with something other than a slash 
Note: See TracChangeset for help on using the changeset viewer.