Changeset 18906 for lang/javascript
- Timestamp:
- 09/06/08 02:01:02 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/relative_move.js
r15953 r18906 19 19 (function (){ 20 20 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; 24 25 return res; 25 26 } … … 28 29 var win = window.content.window; 29 30 var loc = win.location; 30 var splited_path = path.split( "/");31 var splited_path = path.split(/\/+/); 31 32 var up = 0; 32 33 … … 49 50 } 50 51 52 var url, base; 51 53 switch(up){ 52 54 case -2: // "/hoge" 53 varbase = loc.protocol + "//" + loc.hostname;54 varurl = base + path;55 base = loc.protocol + "//" + loc.hostname; 56 url = base + path; 55 57 break; 56 58 case -1: // "./hoge" 57 var _r = null; 58 var base = trim_query(loc.href); 59 base = trim_query(loc.href); 59 60 path = path.substring(2); 60 61 if(base[base.length-1] == "/") 61 varurl = base + path;62 url = base + path; 62 63 else 63 varurl = base + "/" + path;64 url = base + "/" + path; 64 65 break; 65 66 case 0: // "hoge" 66 varurl = loc.href + path;67 url = loc.href + path; 67 68 break; 68 69 default: // "../../hoge" 69 varbase = trim_query(loc.href);70 varc = 0;70 base = trim_query(loc.href); 71 let c = 0; 71 72 while(c < up){ 72 73 if(c > 0) base = base.substr(0, base.length-1); 73 base = base.match(/^(.*\/)[^\/]*$/)[1];74 [base] = base.match(/^.*\/(?=[^\/]*$)/); 74 75 path = path.substring(3); 75 76 c++; 76 77 } 77 varurl = base + path;78 url = base + path; 78 79 break; 79 80 } … … 84 85 ["ro[pen]"], 85 86 "Open relative URL in the current tab", 86 function(path){ 87 open_path(path); 88 } 87 open_path 89 88 ); 90 89
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)