URILink for encoding all URIs; fixes #220; current_track now just a URI
This commit is contained in:
53
src/js/components/URILink.js
Executable file
53
src/js/components/URILink.js
Executable file
@ -0,0 +1,53 @@
|
||||
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
export default class URILink extends React.Component{
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
|
||||
render(){
|
||||
var to = null;
|
||||
var uri = encodeURIComponent(this.props.uri);
|
||||
|
||||
switch (this.props.type){
|
||||
|
||||
case 'playlist':
|
||||
to = global.baseURL+'playlist/'+uri;
|
||||
break;
|
||||
|
||||
case 'artist':
|
||||
to = global.baseURL+'artist/'+uri;
|
||||
break;
|
||||
|
||||
case 'album':
|
||||
to = global.baseURL+'album/'+uri;
|
||||
break;
|
||||
|
||||
case 'track':
|
||||
to = global.baseURL+'track/'+uri;
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
to = global.baseURL+'user/'+uri;
|
||||
break;
|
||||
|
||||
case 'recommendations':
|
||||
to = global.baseURL+'discover/recommendations/'+uri;
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
className={this.props.className ? this.props.className : null}
|
||||
to={to}>
|
||||
{this.props.children}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user