| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ package-lock.json | |||
| 21 | 21 | .c9/ | |
| 22 | 22 | *.launch | |
| 23 | 23 | .settings/ | |
| 24 | + .atom | ||
| 24 | 25 | ||
| 25 | 26 | # IDE - VSCode | |
| 26 | 27 | .vscode/* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | 1 | import { createViewFromEntry } from "tns-core-modules/ui/builder"; | |
| 2 | + import { sanitizeModuleName } from "tns-core-modules/ui/builder/module-name-sanitizer"; | ||
| 3 | + | ||
| 2 | 4 | import { assertEqual, assertNull, assertThrows, assertNotNull } from "../../tk-unit"; | |
| 3 | 5 | ||
| 4 | 6 | const COMPONENT_MODULE = "ui/builder/component-module"; | |
@@ -35,4 +37,14 @@ export function test_create_view_from_entry_with_path_with_slash() { | |||
| 35 | 37 | export function test_create_view_from_entry_with_path_with_tilde() { | |
| 36 | 38 | const view = getViewComponent("~/" + COMPONENT_MODULE); | |
| 37 | 39 | assertNotNull(view, `Module starting with "~/" could not be loaded`); | |
| 38 | - } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + export function test_sanitize_module_name_with_removable_extension() { | ||
| 43 | + const moduleName = sanitizeModuleName("./xml-declaration/mainPage.xml"); | ||
| 44 | + assertEqual(moduleName, "./xml-declaration/mainPage"); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + export function test_sanitize_module_name_with_non_removable_extension() { | ||
| 48 | + const moduleName = sanitizeModuleName("app/views/main.page"); | ||
| 49 | + assertEqual(moduleName, "app/views/main.page"); | ||
| 50 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,11 +10,10 @@ export function sanitizeModuleName(moduleName: string, removeExtension: boolean | |||
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | 12 | if (removeExtension) { | |
| 13 | - const lastDot = moduleName.lastIndexOf("."); | ||
| 14 | - if (lastDot > 0) { | ||
| 15 | - moduleName = moduleName.substr(0, lastDot); | ||
| 16 | - } | ||
| 13 | + const extToRemove = ["js", "ts", "xml", "html", "css", "scss"]; | ||
| 14 | + const extensionRegEx = new RegExp(`(.*)\\.(?:${extToRemove.join("|")})`, "i"); | ||
| 15 | + moduleName = moduleName.replace(extensionRegEx, "$1"); | ||
| 17 | 16 | } | |
| 18 | 17 | ||
| 19 | 18 | return moduleName; | |
| 20 | - } | ||
| 19 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments