Merge branch '1395-hashtags-imported-with-not-allowed-chars' of https://github.com/Human-Connection/Human-Connection into 1395-hashtags-imported-with-not-allowed-chars

This commit is contained in:
Wolfgang Huß 2019-09-04 13:59:04 +02:00
commit bf511940ad
6 changed files with 11 additions and 31291 deletions

11673
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -100,7 +100,6 @@
"slug": "~1.1.0",
"trunc-html": "~1.1.2",
"uuid": "~3.3.3",
"wait-on": "~3.3.0",
"xregexp": "^4.2.4"
},
"devDependencies": {
@ -131,4 +130,4 @@
"prettier": "~1.18.2",
"supertest": "~4.0.2"
}
}
}

View File

@ -20,8 +20,8 @@ export default function(content) {
.get()
const hashtags = []
urls.forEach(url => {
let match
if ((match = exec(url, regX)) != null) {
const match = exec(url, regX)
if (match != null) {
hashtags.push(match[1])
}
})

View File

@ -125,7 +125,6 @@
[ ] wasSeeded: { type: Boolean }
}
*/
CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as post
MERGE (p:Post {id: post._id["$oid"]})
ON CREATE SET
@ -148,9 +147,12 @@ MATCH (c:Category {id: categoryId})
MERGE (p)-[:CATEGORIZED]->(c)
WITH p, post.tags AS tags
UNWIND tags AS tag
CALL apoc.when(tag =~ '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$', 'RETURN tag', '', {tag: tag})
WITH '[^\\p{L}0-9]' as regexMatchAllNonUnicodeOrDigits
WITH apoc.text.replace(tag, regexMatchAllNonUnicodeOrDigits, '') as tagNoSpacesAllowed
WITH '^((\\p{L}+[\\p{L}0-9]*)|([0-9]+\\p{L}+[\\p{L}0-9]*))$' as regexHashtagMustNotIncludeOnlyDigits
CALL apoc.when(tagNoSpacesAllowed =~ regexHashtagMustNotIncludeOnlyDigits, 'RETURN tagNoSpacesAllowed', '', {tagNoSpacesAllowed: tagNoSpacesAllowed})
YIELD value as validated
WHERE validated.tag IS NOT NULL
MERGE (t:Tag { id: validated.tag, disabled: false, deleted: false })
WHERE validated.tagNoSpacesAllowed IS NOT NULL
MERGE (t:Tag { id: validated.tagNoSpacesAllowed, disabled: false, deleted: false })
MERGE (p)-[:TAGGED]->(t)
;

View File

@ -215,9 +215,8 @@ export default {
},
sanitizeQuery(query) {
if (this.suggestionType === HASHTAG) {
// remove all unallowed chars
const regX = build('[^\\pL0-9]')
query = replace(query, regX, '', 'all')
const regexMatchAllNonUnicodeOrDigits = build('[^\\pL0-9]')
query = replace(query, regexMatchAllNonUnicodeOrDigits, '', 'all')
// if the query is only made of digits, make it empty
return query.replace(/[0-9]/gm, '') === '' ? '' : query
}

19607
webapp/package-lock.json generated

File diff suppressed because it is too large Load Diff