Skip to content

Commit

Permalink
Browse URI + name syntax, fixes #829
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Sep 4, 2022
1 parent d165aa6 commit 0f950ed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/js/components/AddedFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export default ({
break;

case 'browse':
let directory = '';
if (uri.indexOf('file://')) {
directory = uri.substr(uri.lastIndexOf('/'), uri.length);
}
link = (
<URILink type={type} uri={uri}>
<URILink type={type} uri={uri} suffix={directory}>
<I18n path="library.browse.title" />
</URILink>
);
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/URILink.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default memo(({
handleContextMenu,
children,
unencoded,
suffix,
}) => {
let to = null;
const uriType = type || uriTypeHelper(rawUri);
Expand Down Expand Up @@ -37,7 +38,7 @@ export default memo(({
break;

case 'browse':
to = `/library/browse/${uri}`;
to = `/library/browse/${uri}${suffix ? `/${suffix}` : ''}`;
break;

case 'recommendations':
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Library/Browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Browse extends React.Component {

grid_items.push({
name: subdirectory.name,
link: `/library/browse/${encodeURIComponent(subdirectory.name)}/${encodeUri(subdirectory.uri)}`,
link: `/library/browse/${encodeUri(subdirectory.uri)}/${encodeURIComponent(subdirectory.name)}`,
icons: formatImages(subdirectory.icons),
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Library/BrowseDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Subdirectories = ({ items, view }) => {
// Only define the link for directories; allows URILink to intelligently route based on type
const link = (item) => (
item.type === 'directory'
? `/library/browse/${encodeURIComponent(item.name)}/${encodeUri(item.uri)}`
? `/library/browse/${encodeUri(item.uri)}/${encodeURIComponent(item.name)}`
: null
);

Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default () => (
element={<Browse />}
/>
<Route
path="browse/:name/:uri"
path="browse/:uri/:name"
element={<BrowseDirectory />}
/>
</Routes>
Expand Down

0 comments on commit 0f950ed

Please sign in to comment.