Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EIT-SWE
ux
utils
Commits
2b2c3fc7
Commit
2b2c3fc7
authored
Apr 29, 2020
by
Ryan Diehl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cdn): makes CDN_CONFIG optional
this helps especially with testing
parent
7b0d4934
Pipeline
#97138
passed with stages
in 6 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
libs/utils/cdn/src/lib/cdn.service.spec.ts
libs/utils/cdn/src/lib/cdn.service.spec.ts
+18
-0
libs/utils/cdn/src/lib/cdn.service.ts
libs/utils/cdn/src/lib/cdn.service.ts
+7
-2
No files found.
libs/utils/cdn/src/lib/cdn.service.spec.ts
View file @
2b2c3fc7
...
...
@@ -251,3 +251,21 @@ describe('CdnService', () => {
});
});
});
describe
(
'
CdnService with no CDN_CONFIG
'
,
()
=>
{
let
service
:
CdnService
;
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
providers
:
[
CdnService
]
});
service
=
TestBed
.
get
(
CdnService
);
});
it
(
'
should create
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
it
(
'
should use default baseUrl
'
,
()
=>
{
expect
(
service
.
uri
(
'
test
'
)).
toBe
(
'
https://static.apps.psu.edu/test
'
);
});
});
libs/utils/cdn/src/lib/cdn.service.ts
View file @
2b2c3fc7
...
...
@@ -15,7 +15,9 @@ import { CdnUri } from './cdn.model';
@
Injectable
({
providedIn
:
'
root
'
})
export
class
CdnService
{
constructor
(
@
Inject
(
CDN_CONFIG
)
private
config
:
CdnConfig
,
@
Optional
()
@
Inject
(
CDN_CONFIG
)
private
config
:
CdnConfig
,
@
Optional
()
@
Inject
(
CDN_RESOURCE_CONFIG
)
private
resourceConfig
:
CdnResourceConfig
[],
...
...
@@ -25,7 +27,10 @@ export class CdnService {
)
{}
private
get
cdnUrl
():
string
{
let
url
=
this
.
config
.
baseUrl
||
'
https://static.apps.psu.edu
'
;
let
url
=
'
https://static.apps.psu.edu
'
;
if
(
this
.
config
&&
this
.
config
.
baseUrl
)
{
url
=
this
.
config
.
baseUrl
;
}
if
(
url
&&
url
.
lastIndexOf
(
'
/
'
)
===
url
.
length
-
1
)
{
url
=
url
.
substr
(
0
,
url
.
length
-
1
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment