-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: use urlAfterRedirects to load prerendered content #299 prevent loading content for the page that user is not going to end up at but instead actually load content for page where user will end up after navigation * fix: fix loading of content for the root route #298 * fix: prevent flicker of content when navigating to the root route #300 * refactor(ng-lib): simplify #300 fix * fix(ng-lib): fallback to url when urlAfterRedirects is unspecified
- Loading branch information
1 parent
38905e8
commit 4eefc2f
Showing
3 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
projects/scullyio/ng-lib/src/lib/utils/merge-paths.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {mergePaths} from './merge-paths'; | ||
|
||
describe('mergePaths', () => { | ||
it('should return correct concatenated path', () => { | ||
expect(mergePaths('/about', '/index.html')).toBe('about/index.html'); | ||
}); | ||
|
||
it('should return correct concatenated path when base ends with slash and path starts with slash', () => { | ||
expect(mergePaths('/about/', '/index.html')).toBe('about/index.html'); | ||
}); | ||
|
||
it('should return correct concatenated path when base does not end with slash and path does not start with slash', () => { | ||
expect(mergePaths('/about', 'index.html')).toBe('about/index.html'); | ||
}); | ||
|
||
it('should return correct concatenated path when base is a slash and path does not start with slash', () => { | ||
expect(mergePaths('/', '/index.html')).toBe('/index.html'); | ||
}); | ||
}); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function mergePaths(base: string, path: string): string { | ||
if (base.endsWith('/') && path.startsWith('/')) { | ||
return `${base}${path.substr(1)}`; | ||
} | ||
if (!base.endsWith('/') && !path.startsWith('/')) { | ||
return `${base}/${path}`; | ||
} | ||
return `${base}${path}`; | ||
} |