Changeset 18906 for lang/javascript

Show
Ignore:
Timestamp:
09/06/08 02:01:02 (3 months ago)
Author:
drry
Message:
  • fixed a missing var for the _r.
  • et cetera.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/relative_move.js

    r15953 r18906  
    1919(function (){ 
    2020    function trim_query(url){ 
    21         var res = (_r = url.match(/^(.*)\?/)) ? _r[1] : url; 
    22         res = (_r = res.match(/^(http.*)http/)) ? _r[1] : res; 
    23         res = (_r = url.match(/^(.*)#/)) ? _r[1] : res; 
     21        var _r; 
     22        var res = (_r = url.match(/^.*(?=\?)/)) ? _r[0] : url; 
     23        res = (_r = res.match(/^https?:\/\/.*(?=https?:\/\/)/)) ? _r[0] : res; 
     24        res = (_r = url.match(/^.*(?=#)/)) ? _r[0] : res; 
    2425        return res; 
    2526    } 
     
    2829        var win = window.content.window; 
    2930        var loc = win.location; 
    30         var splited_path = path.split("/"); 
     31        var splited_path = path.split(/\/+/); 
    3132        var up = 0; 
    3233 
     
    4950        } 
    5051 
     52        var url, base; 
    5153        switch(up){ 
    5254            case -2: // "/hoge" 
    53                 var base = loc.protocol + "//" + loc.hostname; 
    54                 var url = base + path; 
     55                base = loc.protocol + "//" + loc.hostname; 
     56                url = base + path; 
    5557                break; 
    5658            case -1: // "./hoge" 
    57                 var _r = null; 
    58                 var base = trim_query(loc.href); 
     59                base = trim_query(loc.href); 
    5960                path = path.substring(2); 
    6061                if(base[base.length-1] == "/") 
    61                     var url = base + path; 
     62                    url = base + path; 
    6263                else 
    63                     var url = base + "/" + path; 
     64                    url = base + "/" + path; 
    6465                break; 
    6566            case 0: // "hoge" 
    66                 var url = loc.href + path; 
     67                url = loc.href + path; 
    6768                break; 
    6869            default: // "../../hoge" 
    69                 var base = trim_query(loc.href); 
    70                 var c = 0; 
     70                base = trim_query(loc.href); 
     71                let c = 0; 
    7172                while(c < up){ 
    7273                    if(c > 0) base = base.substr(0, base.length-1); 
    73                     base = base.match(/^(.*\/)[^\/]*$/)[1]; 
     74                    [base] = base.match(/^.*\/(?=[^\/]*$)/); 
    7475                    path = path.substring(3); 
    7576                    c++; 
    7677                } 
    77                 var url = base + path; 
     78                url = base + path; 
    7879            break; 
    7980        } 
     
    8485        ["ro[pen]"], 
    8586        "Open relative URL in the current tab", 
    86         function(path){ 
    87             open_path(path); 
    88         } 
     87        open_path 
    8988    ); 
    9089