canonical url and transform updates
This commit is contained in:
parent
decf0623fb
commit
ad810d5c9e
7 changed files with 28 additions and 20 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -5574,8 +5574,8 @@
|
|||
}
|
||||
},
|
||||
"lbry-redux": {
|
||||
"version": "github:lbryio/lbry-redux#c74deed2a63e1acd0d1827ed9b954242d74e2a1e",
|
||||
"from": "github:lbryio/lbry-redux#c74deed2a63e1acd0d1827ed9b954242d74e2a1e",
|
||||
"version": "github:lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
|
||||
"from": "github:lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
|
||||
"requires": {
|
||||
"proxy-polyfill": "0.1.6",
|
||||
"reselect": "^3.0.0",
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"gfycat-style-urls": "^1.0.3",
|
||||
"lbry-redux": "lbryio/lbry-redux#c74deed2a63e1acd0d1827ed9b954242d74e2a1e",
|
||||
"lbry-redux": "lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
|
||||
"lbryinc": "lbryio/lbryinc#4c761084990557d379c85e1c998fcae7e5db143a",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
|
|
|
@ -40,7 +40,7 @@ import {
|
|||
} from 'lbryinc';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { decode as atob } from 'base-64';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
@ -413,7 +413,7 @@ class AppWithNavigationState extends React.Component {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
dispatchNavigateToUri(dispatch, nav, evt.url);
|
||||
dispatchNavigateToUri(dispatch, nav, transformUrl(evt.url));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -204,12 +204,7 @@ class ClaimList extends React.PureComponent {
|
|||
|
||||
const options = this.buildClaimSearchOptions();
|
||||
const claimSearchKey = createNormalizedClaimSearchKey(options);
|
||||
let uris = claimSearchByQuery[claimSearchKey];
|
||||
|
||||
if (uris) {
|
||||
// temporary workaround for missing short_urls
|
||||
uris = uris.filter(uri => uri && uri.length > 0);
|
||||
}
|
||||
const uris = claimSearchByQuery[claimSearchKey];
|
||||
|
||||
if (Constants.ORIENTATION_VERTICAL === orientation) {
|
||||
return (
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import React from 'react';
|
||||
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
|
||||
import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import { navigateToUri, transformUrl } from 'utils/helper';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import UriBarItem from './internal/uri-bar-item';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
@ -109,12 +109,19 @@ class UriBar extends React.PureComponent {
|
|||
handleSubmitEditing = () => {
|
||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
||||
if (this.state.inputText) {
|
||||
let inputText = this.state.inputText;
|
||||
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
|
||||
let inputText = this.state.inputText,
|
||||
inputTextIsUrl = false;
|
||||
if (inputText.startsWith('lbry://')) {
|
||||
const transformedUrl = transformUrl(inputText);
|
||||
// if it's a URI (lbry://...), open the file page
|
||||
const uri = normalizeURI(inputText);
|
||||
navigateToUri(navigation, uri);
|
||||
} else {
|
||||
if (transformedUrl && isURIValid(transformedUrl)) {
|
||||
inputTextIsUrl = true;
|
||||
navigateToUri(navigation, transformedUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// couldn't parse the inputText as a URL for some reason, so do a search instead
|
||||
if (!inputTextIsUrl) {
|
||||
updateSearchQuery(inputText);
|
||||
// Not a URI, default to a search request
|
||||
if (onSearchSubmitted) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
|
|||
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import { decode as atob } from 'base-64';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import { navigateToUri, transformUrl } from 'utils/helper';
|
||||
import moment from 'moment';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
|
@ -81,7 +81,7 @@ class SplashScreen extends React.PureComponent {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
navigateToUri(navigation, launchUrl);
|
||||
navigateToUri(navigation, transformUrl(launchUrl));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import { buildURI, isURIValid } from 'lbry-redux';
|
||||
import { buildURI, isURIValid, normalizeURI } from 'lbry-redux';
|
||||
import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
|
@ -246,6 +246,12 @@ export function getOrderBy(item) {
|
|||
return orderBy;
|
||||
}
|
||||
|
||||
// replace occurrences of ':' with '#' in a url (entered in the URI bar)
|
||||
export function transformUrl(url) {
|
||||
const start = 'lbry://'.length;
|
||||
return normalizeURI(url.substring(start).replace(/:/g, '#'));
|
||||
}
|
||||
|
||||
// i18n placeholder until we find a good react-native i18n module
|
||||
export function __(str) {
|
||||
return str;
|
||||
|
|
Loading…
Reference in a new issue