From acddd1f34d9a898ce422230f249fd80525bfe124 Mon Sep 17 00:00:00 2001 From: DimitrisRK <55595100+DimitrisRK@users.noreply.github.com> Date: Sat, 20 Jun 2020 01:36:13 +0300 Subject: [PATCH] chore: testing #8637 (#8658) Co-authored-by: Dimitris - Rafail Katsampas --- .../file-name-resolver/file-name-resolver.ts | 5 ++++- .../qualifier-matcher/qualifier-matcher.d.ts | 2 +- .../qualifier-matcher/qualifier-matcher.ts | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts b/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts index 6dae02d0c..6634cd9d8 100644 --- a/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts +++ b/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts @@ -4,7 +4,7 @@ import { path as fsPath, Folder, File } from "../file-system"; import * as trace from "../../trace"; import * as appCommonModule from "../../application/application-common"; -import { findMatch } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher"; +import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher"; export class FileNameResolver implements FileNameResolverDefinition { private _context: PlatformContext; @@ -36,6 +36,9 @@ export class FileNameResolver implements FileNameResolverDefinition { path = fsPath.normalize(path); ext = "." + ext; + // This call will return a clean path without qualifiers + path = stripQualifiers(path); + const candidates = this.getFileCandidatesFromFolder(path, ext); result = findMatch(path, ext, candidates, this._context); diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts index 1279a7928..b278e078d 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts @@ -12,4 +12,4 @@ export interface PlatformContext { export function findMatch(path: string, ext: string, candidates: Array, context: PlatformContext): string; -export function stripQualifiers(path: string): string +export function stripQualifiers(path: string): string; diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts index 8b4f7487f..28b641d14 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts @@ -15,7 +15,7 @@ const minWidthHeightQualifier: QualifierSpec = { return (new RegExp(`.${MIN_WH}\\d+`).test(path)); }, getMatchOccurences: function (path: string): Array { - return path.match(new RegExp(`.${MIN_WH}\\d+`)); + return path.match(new RegExp(`.${MIN_WH}\\d+`, "g")); }, getMatchValue(value: string, context: PlatformContext): number { const numVal = parseInt(value.substr(MIN_WH.length + 1)); @@ -37,7 +37,7 @@ const minWidthQualifier: QualifierSpec = { return (new RegExp(`.${MIN_W}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path)); }, getMatchOccurences: function (path: string): Array { - return path.match(new RegExp(`.${MIN_W}\\d+`)); + return path.match(new RegExp(`.${MIN_W}\\d+`, "g")); }, getMatchValue(value: string, context: PlatformContext): number { const numVal = parseInt(value.substr(MIN_W.length + 1)); @@ -59,7 +59,7 @@ const minHeightQualifier: QualifierSpec = { return (new RegExp(`.${MIN_H}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path)); }, getMatchOccurences: function (path: string): Array { - return path.match(new RegExp(`.${MIN_H}\\d+`)); + return path.match(new RegExp(`.${MIN_H}\\d+`, "g")); }, getMatchValue(value: string, context: PlatformContext): number { const numVal = parseInt(value.substr(MIN_H.length + 1)); @@ -81,7 +81,7 @@ const platformQualifier: QualifierSpec = { return path.includes(".android") || path.includes(".ios"); }, getMatchOccurences: function (path: string): Array { - return [".android", ".ios"]; + return path.match(new RegExp("\\.android|\\.ios", "g")); }, getMatchValue(value: string, context: PlatformContext): number { const val = value.substr(1); @@ -95,7 +95,7 @@ const orientationQualifier: QualifierSpec = { return path.includes(".land") || path.includes(".port"); }, getMatchOccurences: function (path: string): Array { - return [".land", ".port"]; + return path.match(new RegExp("\\.land|\\.port", "g")); }, getMatchValue(value: string, context: PlatformContext): number { const val = value.substr(1);