FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: dots can now be used in module names by surdu · Pull Request #7655 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (2) dotfile  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions .gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package-lock.json
.c9/
*.launch
.settings/
.atom

# IDE - VSCode
.vscode/*
Expand Down
14 changes: 13 additions & 1 deletion tests/app/ui/builder/builder-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { createViewFromEntry } from "tns-core-modules/ui/builder";
import { sanitizeModuleName } from "tns-core-modules/ui/builder/module-name-sanitizer";

import { assertEqual, assertNull, assertThrows, assertNotNull } from "../../tk-unit";

const COMPONENT_MODULE = "ui/builder/component-module";
Expand Down Expand Up @@ -35,4 +37,14 @@ export function test_create_view_from_entry_with_path_with_slash() {
export function test_create_view_from_entry_with_path_with_tilde() {
const view = getViewComponent("~/" + COMPONENT_MODULE);
assertNotNull(view, `Module starting with "~/" could not be loaded`);
}
}

export function test_sanitize_module_name_with_removable_extension() {
const moduleName = sanitizeModuleName("./xml-declaration/mainPage.xml");
assertEqual(moduleName, "./xml-declaration/mainPage");
}

export function test_sanitize_module_name_with_non_removable_extension() {
const moduleName = sanitizeModuleName("app/views/main.page");
assertEqual(moduleName, "app/views/main.page");
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ export function sanitizeModuleName(moduleName: string, removeExtension: boolean
}

if (removeExtension) {
const lastDot = moduleName.lastIndexOf(".");
if (lastDot > 0) {
moduleName = moduleName.substr(0, lastDot);
}
const extToRemove = ["js", "ts", "xml", "html", "css", "scss"];
const extensionRegEx = new RegExp(`(.*)\\.(?:${extToRemove.join("|")})`, "i");
moduleName = moduleName.replace(extensionRegEx, "$1");
}

return moduleName;
}
}

Back | FazBrowse Home | New Git URL