Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 2e40340

Browse files
committed
fix(deep-linking): ensure hasExistingDeepLinkConfig returns true where there is a config referenced by a variable
1 parent 564bd61 commit 2e40340

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/deep-linking/util.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,45 @@ export class AppModule {}
15451545
const result = util.hasExistingDeepLinkConfig(knownPath, knownContent);
15461546
expect(result).toEqual(false);
15471547
});
1548+
1549+
it('should return true where there is an existing deep link config associated with a variable', () => {
1550+
const knownContent = `
1551+
import { BrowserModule } from '@angular/platform-browser';
1552+
import { NgModule } from '@angular/core';
1553+
import { IonicApp, IonicModule } from 'ionic-angular';
1554+
import { MyApp } from './app.component';
1555+
1556+
import { HomePageModule } from '../pages/home/home.module';
1557+
1558+
const deepLinkConfig = {
1559+
links: [
1560+
{ loadChildren: '../pages/page-one/page-one.module#PageOneModule', name: 'PageOne' },
1561+
{ loadChildren: '../pages/page-two/page-two.module#PageTwoModule', name: 'PageTwo' },
1562+
{ loadChildren: '../pages/page-three/page-three.module#PageThreeModule', name: 'PageThree' }
1563+
]
1564+
};
1565+
1566+
@NgModule({
1567+
declarations: [
1568+
MyApp,
1569+
],
1570+
imports: [
1571+
BrowserModule,
1572+
IonicModule.forRoot(MyApp, {}, deepLinkConfig),
1573+
HomePageModule,
1574+
],
1575+
bootstrap: [IonicApp],
1576+
providers: []
1577+
})
1578+
export class AppModule {}
1579+
`;
1580+
1581+
const knownPath = join(process.cwd(), 'idk', 'some', 'fake', 'path');
1582+
1583+
const result = util.hasExistingDeepLinkConfig(knownPath, knownContent);
1584+
expect(result).toEqual(true);
1585+
});
1586+
15481587
});
15491588

15501589
describe('convertDeepLinkEntryToJsObjectString', () => {

src/deep-linking/util.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,17 @@ export function hasExistingDeepLinkConfig(appNgModuleFilePath: string, appNgModu
234234
}
235235

236236
const deepLinkConfigArg = functionCall.arguments[2];
237-
return deepLinkConfigArg.kind === SyntaxKind.ObjectLiteralExpression;
237+
if (deepLinkConfigArg.kind === SyntaxKind.NullKeyword || deepLinkConfigArg.kind === SyntaxKind.UndefinedKeyword) {
238+
return false;
239+
}
240+
241+
if (deepLinkConfigArg.kind === SyntaxKind.ObjectLiteralExpression) {
242+
return true;
243+
}
244+
245+
if ((deepLinkConfigArg as Identifier).text && (deepLinkConfigArg as Identifier).text.length > 0) {
246+
return true;
247+
}
238248
}
239249

240250
function getIonicModuleForRootCall(decorator: Decorator) {

0 commit comments

Comments
 (0)