@scaff/kit
Advanced tools
| /** | ||
| * Translate Template to Regexp | ||
| * "\": %5C | ||
| * "/": %2F | ||
| * ========== ========== ========== | ||
| */ | ||
| export default template => { | ||
| // Change . to \. | ||
| template = template.replace(/\./g, '%5C.'); | ||
| // Change ** to Path | ||
| template = template.replace(/\/\*{2}/g, '(/([%5Cw%5C-%5C.]+)){1,}'); | ||
| // Change * to File | ||
| template = template.replace(/\*/g, '([%5Cw%5C-%5C.]+)'); | ||
| // Change / to \/ | ||
| template = template.replace(/\//g, '%5C%2F'); | ||
| // Instantiate Template | ||
| return new RegExp(decodeURIComponent(template)); | ||
| }; |
+16
-1
@@ -0,7 +1,22 @@ | ||
| // Use Foreach | ||
| import foreach from './foreach'; | ||
| // Match Name of Path with Rule | ||
| export default (path, exp) => { | ||
| // No Empty | ||
| if (exp) { | ||
| // Get Matcher | ||
| const matcher = exp.exec(path); // path.match(exp); | ||
| // Get Raggae | ||
| const raggae = path.match(exp)[2]; | ||
| let raggae = ''; | ||
| // Loop | ||
| foreach(matcher, (item, index) => { | ||
| // Pass 0 and 1 | ||
| if (index) { | ||
| raggae += `${raggae ? '-' : ''}${matcher[index].replace(/\//g, '-')}`; | ||
| } | ||
| }); | ||
| // Only has Raggae | ||
@@ -8,0 +23,0 @@ if (raggae) { |
+7
-10
@@ -0,1 +1,4 @@ | ||
| // Use path-to-regexp | ||
| import { pathToRegexp, match, parse, compile } from 'path-to-regexp'; | ||
| /** | ||
@@ -8,16 +11,10 @@ * Translate Template to Regexp | ||
| export default template => { | ||
| // Change . to \. | ||
| template = template.replace(/\./g, '%5C.'); | ||
| // Change * to File | ||
| template = template.replace(/\*{1}\./g, ':file.'); | ||
| // Change ** to Path | ||
| template = template.replace(/\/\*{2}/g, '(/([%5Cw%5C-%5C.]+)){1,}'); | ||
| template = template.replace(/\*{2}/g, '(.*)'); | ||
| // Change * to File | ||
| template = template.replace(/\*/g, '([%5Cw%5C-%5C.]+)'); | ||
| // Change / to \/ | ||
| template = template.replace(/\//g, '%5C%2F'); | ||
| // Instantiate Template | ||
| return new RegExp(decodeURIComponent(template)); | ||
| return pathToRegexp(template); | ||
| }; |
+4
-3
| { | ||
| "name": "@scaff/kit", | ||
| "version": "3.2.3", | ||
| "version": "3.3.2", | ||
| "main": "dist/index.js", | ||
@@ -8,5 +8,6 @@ "author": "joenix", | ||
| "dependencies": { | ||
| "foreach.js": "^2.1.6" | ||
| "foreach.js": "^2.1.7", | ||
| "path-to-regexp": "^6.2.0" | ||
| }, | ||
| "gitHead": "c3e8be38956f0697233a130131f044600a67fff9" | ||
| "gitHead": "ab7ee21ad1274ec157115487b1894519079d92c0" | ||
| } |
+2
-0
| # @scaff/kit | ||
| > a package for kit use in vue | ||
| 2020.4 |
15226
5.42%26
4%526
5.62%6
50%2
100%+ Added
+ Added
Updated