mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 03:25:24 +03:00
Added open link on search input feature
This commit is contained in:
parent
c9edaa01e3
commit
5946669d84
@ -68,20 +68,26 @@ class SearchModalContainer extends PureComponent {
|
||||
this.setState({ searchResults: { type: 'tag', data: tags } });
|
||||
});
|
||||
} else if (text.includes('https')) {
|
||||
console.log('test :');
|
||||
console.log('postUrlParser(text) :', postUrlParser(text));
|
||||
const { author, permlink } = postUrlParser(text);
|
||||
console.log('author, permlink :', author, permlink);
|
||||
if (author && permlink) {
|
||||
if (author) {
|
||||
handleOnClose();
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
},
|
||||
key: permlink,
|
||||
});
|
||||
if (permlink) {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
},
|
||||
key: permlink,
|
||||
});
|
||||
} else {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.PROFILE,
|
||||
params: {
|
||||
username: author,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
search({ q: text }).then(res => {
|
||||
|
@ -1,14 +1,21 @@
|
||||
export default url => {
|
||||
const parseCatAuthorPermlink = u => {
|
||||
const r = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*)/i;
|
||||
const match = u.match(r);
|
||||
if (match && match.length === 5) {
|
||||
const postRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*)/i;
|
||||
const postMatch = u.match(postRegex);
|
||||
if (postMatch && postMatch.length === 5) {
|
||||
return {
|
||||
author: match[3].replace('@', ''),
|
||||
permlink: match[4],
|
||||
author: postMatch[3].replace('@', ''),
|
||||
permlink: postMatch[4],
|
||||
};
|
||||
}
|
||||
const authorRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)/i;
|
||||
const authorMatch = u.match(authorRegex);
|
||||
if (authorMatch && authorMatch.length === 4) {
|
||||
return {
|
||||
author: authorMatch[3].replace('@', ''),
|
||||
permlink: null,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
@ -21,6 +28,14 @@ export default url => {
|
||||
permlink: match[3],
|
||||
};
|
||||
}
|
||||
const authorRegex = /^https?:\/\/(.*)\/(@[\w.\d-]+)/i;
|
||||
const authorMatch = u.match(authorRegex);
|
||||
if (authorMatch && authorMatch.length === 3) {
|
||||
return {
|
||||
author: authorMatch[2].replace('@', ''),
|
||||
permlink: null,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user