Skip to content

Commit 81ecc77

Browse files
authored
Merge pull request #618 from citation-file-format/605-trailing-space
2 parents bcfdc6f + e3d29fa commit 81ecc77

3 files changed

Lines changed: 90 additions & 35 deletions

File tree

src/components/IdentifierCardEditing.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
<script lang="ts">
7575
import { PropType, computed, defineComponent } from 'vue'
76-
import { byError, identifierValueQueries } from 'src/error-filtering'
76+
import { byError, identifierValueQueries, unique } from 'src/error-filtering'
7777
import { IdentifierTypeType } from 'src/types'
7878
import SchemaGuideLink from 'src/components/SchemaGuideLink.vue'
7979
import { useValidation } from 'src/store/validation'
@@ -116,6 +116,7 @@ export default defineComponent({
116116
return identifierValueQueries(props.index, ['doi', 'url', 'swh', 'other'].indexOf(props.type))
117117
.filter(byError(errors.value))
118118
.map(query => query.replace.message)
119+
.filter(unique)
119120
})
120121
return {
121122
typeOptions: [

src/components/ScreenRelatedResources.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
</template>
114114

115115
<script lang="ts">
116-
import { byError, repositoryArtifactQueries, repositoryCodeQueries, repositoryQueries, urlQueries } from 'src/error-filtering'
116+
import { byError, repositoryArtifactQueries, repositoryCodeQueries, repositoryQueries, unique, urlQueries } from 'src/error-filtering'
117117
import { computed, defineComponent, onUpdated, ref } from 'vue'
118118
import InfoDialog from 'components/InfoDialog.vue'
119119
import { useCff } from 'src/store/cff'
@@ -139,21 +139,25 @@ export default defineComponent({
139139
return repositoryCodeQueries
140140
.filter(byError(errors.value))
141141
.map(query => query.replace.message)
142+
.filter(unique)
142143
})
143144
const urlErrors = computed(() => {
144145
return urlQueries
145146
.filter(byError(errors.value))
146147
.map(query => query.replace.message)
148+
.filter(unique)
147149
})
148150
const repositoryErrors = computed(() => {
149151
return repositoryQueries
150152
.filter(byError(errors.value))
151153
.map(query => query.replace.message)
154+
.filter(unique)
152155
})
153156
const repositoryArtifactErrors = computed(() => {
154157
return repositoryArtifactQueries
155158
.filter(byError(errors.value))
156159
.map(query => query.replace.message)
160+
.filter(unique)
157161
})
158162
const helpData = {
159163
repository: {

src/error-filtering.ts

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export const byError = (errors: ErrorObject[], matcher: Comparator = defaultMatc
4040
}
4141
}
4242

43+
export const unique = (message: string, index: number, self: string[]) => {
44+
return self.indexOf(message) === index
45+
}
46+
4347
export const authorsQueries: ErrorQuery[] = [{
4448
find: {
4549
instancePath: '/authors',
@@ -112,44 +116,58 @@ export const emailQueries = (index: number) => {
112116
}
113117

114118
export const identifierValueQueries = (index: number, typeIndex: number) => {
115-
return [[
116-
{
117-
find: {
118-
instancePath: `/identifiers/${index}/value`,
119-
schemaPath: '#/definitions/doi/pattern'
120-
},
121-
replace: {
122-
message: 'e.g. \'10.5281/zenodo.1003149\' or \'10.7717/peerj-cs.86\'. Does not include the resolver URL.'
119+
return [
120+
[
121+
{
122+
find: {
123+
instancePath: `/identifiers/${index}/value`,
124+
schemaPath: '#/definitions/doi/pattern'
125+
},
126+
replace: {
127+
message: 'e.g. \'10.5281/zenodo.1003149\' or \'10.7717/peerj-cs.86\'. Does not include the resolver URL.'
128+
}
123129
}
124-
},
125-
{
126-
find: {
127-
instancePath: `/identifiers/${index}/value`,
128-
schemaPath: '#/definitions/url/pattern'
130+
], [
131+
{
132+
find: {
133+
instancePath: `/identifiers/${index}/value`,
134+
schemaPath: '#/definitions/url/pattern'
135+
},
136+
replace: {
137+
message: 'e.g. \'https://www.example.com\' (http, ftp, sftp hyperlinks are also supported)'
138+
}
129139
},
130-
replace: {
131-
message: 'e.g. \'https://www.example.com\' (http, ftp, sftp hyperlinks are also supported)'
140+
{
141+
find: {
142+
instancePath: `/identifiers/${index}/value`,
143+
schemaPath: '#/definitions/url/format'
144+
},
145+
replace: {
146+
message: 'e.g. \'https://www.example.com\' (http, ftp, sftp hyperlinks are also supported)'
147+
}
132148
}
133-
},
134-
{
135-
find: {
136-
instancePath: `/identifiers/${index}/value`,
137-
schemaPath: '#/definitions/swh-identifier/pattern'
138-
},
139-
replace: {
140-
message: 'e.g. \'swh:1:rev:309cf2674ee7a0749978cf8265ab91a60aea0f7d\'. Besides \'rev\', other allowed values are: \'snp\', \'rel\', \'dir\', and \'cnt\'.'
149+
], [
150+
{
151+
find: {
152+
instancePath: `/identifiers/${index}/value`,
153+
schemaPath: '#/definitions/swh-identifier/pattern'
154+
},
155+
replace: {
156+
message: 'e.g. \'swh:1:rev:309cf2674ee7a0749978cf8265ab91a60aea0f7d\'. Besides \'rev\', other allowed values are: \'snp\', \'rel\', \'dir\', and \'cnt\'.'
157+
}
141158
}
142-
},
143-
{
144-
find: {
145-
instancePath: `/identifiers/${index}/value`,
146-
schemaPath: '#/anyOf/3/properties/value/minLength'
147-
},
148-
replace: {
149-
message: 'Zero-length identifier values are not allowed. Please type an identifier value or remove the identifier entirely.'
159+
], [
160+
{
161+
find: {
162+
instancePath: `/identifiers/${index}/value`,
163+
schemaPath: '#/anyOf/3/properties/value/minLength'
164+
},
165+
replace: {
166+
message: 'Zero-length identifier values are not allowed. Please type an identifier value or remove the identifier entirely.'
167+
}
150168
}
151-
}
152-
][typeIndex]] as ErrorQuery[]
169+
]
170+
][typeIndex] as ErrorQuery[]
153171
}
154172

155173
export const identifiersQueries: ErrorQuery[] = [{
@@ -223,6 +241,14 @@ export const repositoryArtifactQueries: ErrorQuery[] = [{
223241
replace: {
224242
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
225243
}
244+
}, {
245+
find: {
246+
instancePath: '/repository-artifact',
247+
schemaPath: '#/definitions/url/format'
248+
},
249+
replace: {
250+
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
251+
}
226252
}]
227253

228254
export const repositoryCodeQueries: ErrorQuery[] = [{
@@ -233,6 +259,14 @@ export const repositoryCodeQueries: ErrorQuery[] = [{
233259
replace: {
234260
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
235261
}
262+
}, {
263+
find: {
264+
instancePath: '/repository-code',
265+
schemaPath: '#/definitions/url/format'
266+
},
267+
replace: {
268+
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
269+
}
236270
}]
237271

238272
export const repositoryQueries: ErrorQuery[] = [{
@@ -243,6 +277,14 @@ export const repositoryQueries: ErrorQuery[] = [{
243277
replace: {
244278
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
245279
}
280+
}, {
281+
find: {
282+
instancePath: '/repository',
283+
schemaPath: '#/definitions/url/format'
284+
},
285+
replace: {
286+
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
287+
}
246288
}]
247289

248290
export const titleQueries: ErrorQuery[] = [{
@@ -272,4 +314,12 @@ export const urlQueries: ErrorQuery[] = [{
272314
replace: {
273315
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
274316
}
317+
}, {
318+
find: {
319+
instancePath: '/url',
320+
schemaPath: '#/definitions/url/format'
321+
},
322+
replace: {
323+
message: 'Format: https://www.example.com (http, ftp, sftp hyperlinks are also supported)'
324+
}
275325
}]

0 commit comments

Comments
 (0)