Last change
on this file since 490 was
443,
checked in by hendrikvanantwerpen, 12 years ago
|
Reorganized for Node --- the SVN gods hate us all!
Lost all historical info on moved files, because SVN is a f *.
Also we have Node now, serving both the static content and forwarding
database requests.
|
File size:
1.4 KB
|
Line | |
---|
1 | define([ |
---|
2 | 'dojo/_base/declare', |
---|
3 | 'dojo/io-query' |
---|
4 | ],function(declare,ioQuery){ |
---|
5 | |
---|
6 | var _paramMatch = /:(\w[\w\d]*)/g; |
---|
7 | var _paramReplace = "([^\\/!]+)"; |
---|
8 | |
---|
9 | var Path = declare(null,{ |
---|
10 | _paramNames: null, |
---|
11 | _matcher: null, |
---|
12 | constructor: function(pattern) { |
---|
13 | var match = null; |
---|
14 | this._paramNames = []; |
---|
15 | while((match = _paramMatch.exec(pattern)) !== null){ |
---|
16 | this._paramNames.push(match[1]); |
---|
17 | } |
---|
18 | pattern = pattern.replace(_paramMatch, _paramReplace); |
---|
19 | this._matcher = new RegExp('^!'+pattern+'(!(.*))?$'); |
---|
20 | }, |
---|
21 | match: function(path) { |
---|
22 | var params = null; |
---|
23 | var result = null; |
---|
24 | if ((result = this._matcher.exec(path)) !== null) { |
---|
25 | var numParams = this._paramNames.length; |
---|
26 | params = {}; |
---|
27 | for (var j = 0; j < numParams; j++) { |
---|
28 | params[this._paramNames[j]] = result[j+1]; |
---|
29 | } |
---|
30 | if ( result.length > numParams+1 && result[numParams+2] ) { |
---|
31 | params.options = ioQuery.queryToObject(result[numParams+2]); |
---|
32 | } |
---|
33 | } |
---|
34 | return params; |
---|
35 | } |
---|
36 | }); |
---|
37 | |
---|
38 | Path.getDefault = function() { |
---|
39 | return "!/"; |
---|
40 | }; |
---|
41 | |
---|
42 | Path.format = function(path,options) { |
---|
43 | var hash = '!'+path; |
---|
44 | if ( options ) { |
---|
45 | hash += '!'+ioQuery.objectToQuery(options); |
---|
46 | } |
---|
47 | return hash; |
---|
48 | }; |
---|
49 | |
---|
50 | return Path; |
---|
51 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.