Skip to content

Commit 52faf4b

Browse files
committed
cleanse path
1 parent a72f7a2 commit 52faf4b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/services/StateService.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,11 @@ export class StateService {
116116
stateLockRequest: StateLockRequest,
117117
): Promise<void> => {
118118
const lockedBy = crypto.createHash('sha256').update(identity.token, 'utf8').digest('base64');
119+
const path = stateLockRequest.Path || '';
119120

120121
let stateLock = await this.stateLockModel.model.get(
121122
StateLockModel.prefix('pk', identity.ownerId),
122-
StateLockModel.prefix(
123-
'sk',
124-
`${identity.repoId}_${identity.workspace}_${stateLockRequest.Path}`,
125-
),
123+
StateLockModel.prefix('sk', `${identity.repoId}_${identity.workspace}_${path}`),
126124
);
127125

128126
if (stateLock && stateLock.attrs.lockedBy !== lockedBy) {
@@ -135,17 +133,14 @@ export class StateService {
135133
// TODO Catch overwrite exception
136134
stateLock = await this.stateLockModel.model.create({
137135
pk: StateLockModel.prefix('pk', identity.ownerId),
138-
sk: StateLockModel.prefix(
139-
'sk',
140-
`${identity.repoId}_${identity.workspace}_${stateLockRequest.Path}`,
141-
),
136+
sk: StateLockModel.prefix('sk', `${identity.repoId}_${identity.workspace}_${path}`),
142137
ownerId: identity.ownerId,
143138
owner: identity.owner,
144139
repoId: identity.repoId,
145140
repo: identity.repo,
146141
workspace: identity.workspace,
147142
id: stateLockRequest.ID,
148-
path: stateLockRequest.Path,
143+
path,
149144
lockedBy,
150145
});
151146

0 commit comments

Comments
 (0)