Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
87d0f56d
Commit
87d0f56d
authored
2 years ago
by
tamaina
Browse files
Options
Downloads
Patches
Plain Diff
fix correctFilename extが.から始まる場合も考慮する
parent
82439850
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/misc/correct-filename.ts
+1
-1
1 addition, 1 deletion
packages/backend/src/misc/correct-filename.ts
packages/backend/test/unit/misc/others.ts
+3
-0
3 additions, 0 deletions
packages/backend/test/unit/misc/others.ts
with
4 additions
and
1 deletion
packages/backend/src/misc/correct-filename.ts
+
1
−
1
View file @
87d0f56d
// 与えられた拡張子とファイル名が一致しているかどうかを確認し、
// 一致していない場合は拡張子を付与して返す
export
function
correctFilename
(
filename
:
string
,
ext
:
string
|
null
)
{
const
dotExt
=
ext
?
`.
${
ext
}
`
:
'
.unknown
'
;
const
dotExt
=
ext
?
ext
.
startsWith
(
'
.
'
)
?
ext
:
`.
${
ext
}
`
:
'
.unknown
'
;
if
(
filename
.
endsWith
(
dotExt
))
{
return
filename
;
}
...
...
This diff is collapsed.
Click to expand it.
packages/backend/test/unit/misc/others.ts
+
3
−
0
View file @
87d0f56d
...
...
@@ -21,6 +21,9 @@ describe('misc:correct-filename', () => {
test
(
'
with same ext
'
,
()
=>
{
expect
(
correctFilename
(
'
filename.jpg
'
,
'
jpg
'
)).
toBe
(
'
filename.jpg
'
);
});
test
(
'
.ext
'
,
()
=>
{
expect
(
correctFilename
(
'
filename.jpg
'
,
'
.jpg
'
)).
toBe
(
'
filename.jpg
'
);
});
test
(
'
with different ext
'
,
()
=>
{
expect
(
correctFilename
(
'
filename.webp
'
,
'
jpg
'
)).
toBe
(
'
filename.webp.jpg
'
);
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment