-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added regex checks for 'Link to Work' and 'Link to Creator Profile' #456
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
279a582
added regex checks to url
soustab10 02e1da3
added year validation
soustab10 8ded40d
Merge branch 'creativecommons:main' into regexcheck
soustab10 788954a
removed vee-validate and updated year validation
soustab10 618a241
removed errors
soustab10 213592d
removed vee-validate dependency
soustab10 6953a35
Merge branch 'creativecommons:main' into regexcheck
soustab10 5d73a61
deleted unused lines and store regex check in variable
soustab10 9afc23c
resolved package-lock.json
Cronus1007 da328de
Merge branch 'main' into regexcheck
possumbilities cc92078
Merge branch 'main' into regexcheck
TimidRobot 68c5962
Merge branch 'main' into regexcheck
TimidRobot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,20 +22,24 @@ | |
</v-input> | ||
<v-input | ||
v-model="workUrl" | ||
v-validate="{ url: { require_protocol: true } }" | ||
:label="$t('stepper.AD.form.work-url.label')" | ||
:placeholder="$t('stepper.AD.form.work-url.placeholder')" | ||
/> | ||
<span v-if="attributionErrorMsg.workUrlError">{{ attributionErrorMsg.workUrlError }}</span> | ||
<v-input | ||
v-model="creatorProfileUrl" | ||
:label="$t('stepper.AD.form.creator-profile.label')" | ||
:placeholder="$t('stepper.AD.form.creator-profile.placeholder')" | ||
/> | ||
<span v-if="attributionErrorMsg.creatorProfileUrlError">{{ attributionErrorMsg.creatorProfileUrlError }}</span> | ||
<v-input | ||
v-if="currentLicenseAttributes.BY" | ||
v-model="yearOfCreation" | ||
:label="$t('stepper.AD.form.year-of-creation.label')" | ||
:placeholder="$t('stepper.AD.form.year-of-creation.placeholder')" | ||
/> | ||
<span v-if="attributionErrorMsg.yearOfCreationError">{{ attributionErrorMsg.yearOfCreationError }}</span> | ||
</form> | ||
|
||
<app-modal | ||
|
@@ -58,7 +62,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; | |
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; | ||
import { library } from '@fortawesome/fontawesome-svg-core'; | ||
library.add(faInfoCircle); | ||
|
||
const regexTestString= /[(http(s)?):(www)?a-zA-Z0-9@:%._~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/; | ||
export default { | ||
name: 'AttributionDetails', | ||
components: { VInput, FontAwesomeIcon }, | ||
|
@@ -74,6 +78,7 @@ export default { | |
data() { | ||
return { | ||
showInfoModal: false, | ||
attributionErrorMsg: [], | ||
}; | ||
}, | ||
computed: { | ||
|
@@ -119,10 +124,55 @@ export default { | |
}, | ||
}, | ||
}, | ||
watch: { | ||
creatorProfileUrl(value){ | ||
this.attributionDetails.creatorProfileUrl = value; | ||
this.validateCreatorProfileUrl(value); | ||
}, | ||
workUrl(value){ | ||
this.attributionDetails.workUrl = value; | ||
this.validateWorkUrl(value); | ||
}, | ||
yearOfCreation(value){ | ||
this.attributionDetails.yearOfCreation = value; | ||
this.validateYearOfCreation(value); | ||
}, | ||
}, | ||
methods: { | ||
toggleInfoModal() { | ||
this.showInfoModal = !this.showInfoModal; | ||
}, | ||
validateCreatorProfileUrl(value) { | ||
if(value.length === 0){ | ||
this.attributionErrorMsg.creatorProfileUrlError = ''; | ||
} | ||
else if (regexTestString.test(value)) { | ||
this.attributionErrorMsg.creatorProfileUrlError = ''; | ||
} else { | ||
this.attributionErrorMsg.creatorProfileUrlError = 'Please enter a valid URL.'; | ||
} | ||
}, | ||
validateWorkUrl(value) { | ||
if(value.length === 0){ | ||
this.attributionErrorMsg.workUrlError = ''; | ||
} | ||
else if (regexTestString.test(value)) { | ||
this.attributionErrorMsg.workUrlError = ''; | ||
} else { | ||
this.attributionErrorMsg.workUrlError = 'Please enter a valid URL.'; | ||
} | ||
}, | ||
validateYearOfCreation(value){ | ||
if(value.length === 0){ | ||
this.attributionErrorMsg.yearOfCreationError = ''; | ||
} | ||
else if(Number(value)>= 1000 && Number(value)<=9999 && !value.includes('.')){ | ||
this.attributionErrorMsg.yearOfCreationError = ''; | ||
} | ||
else { | ||
this.attributionErrorMsg.yearOfCreationError = 'Please enter a valid year'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two digit years are valid, even if imprecise. Also the text is nonblocking. Please update text to something like: |
||
} | ||
}, | ||
...mapMutations([ | ||
'setCreatorName', | ||
'setCreatorProfileUrl', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex has a number of problems (including #456 (comment)).
Maybe use The Perfect URL Regular Expression - Perfect URL Regex: