Custom URI encoding, will require manual handling of all url unsafe characters
This commit is contained in:
@ -119330,6 +119330,9 @@ var MopidyMiddleware = function () {
|
||||
provider: 'mopidy',
|
||||
can_edit: true
|
||||
}));
|
||||
console.debug({
|
||||
playlist: playlist
|
||||
});
|
||||
|
||||
if (response.tracks) {
|
||||
request(store, 'library.lookup', {
|
||||
@ -126658,11 +126661,14 @@ var formatSimpleObjects = function formatSimpleObjects() {
|
||||
*/
|
||||
|
||||
|
||||
var encodeUri = function encodeUri(rawUri) {
|
||||
var encodeUri = function encodeUri() {
|
||||
var rawUri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
var uri = rawUri;
|
||||
uri = uri.replace(/\//g, '%2F');
|
||||
uri = uri.replace(/\?/g, '%3F');
|
||||
return uri; //encodeURIComponent(rawUri);
|
||||
uri = uri.replace(/%/g, '%25'); //uri = encodeURIComponent(uri);
|
||||
|
||||
return uri;
|
||||
};
|
||||
/**
|
||||
* Rebuild a URI with some ugly-ass handling of encoding.
|
||||
@ -126680,32 +126686,14 @@ var encodeUri = function encodeUri(rawUri) {
|
||||
*/
|
||||
|
||||
|
||||
var decodeUri = function decodeUri(rawUri) {
|
||||
var decodeUri = function decodeUri() {
|
||||
var rawUri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
var uri = rawUri;
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/%2F/g, '/');
|
||||
uri = uri.replace(/%3F/g, '?');
|
||||
/**
|
||||
* What if we removed encoding completely? It looks like mopidy URIs are encoded to be URL friendly,
|
||||
* except for slashes. So in principle we could just replace slash with %2F but otherwise not use
|
||||
* encode/decodeUriComponent.
|
||||
*/
|
||||
uri = uri.replace(/%3F/g, '?'); //uri = decodeURIComponent(uri);
|
||||
|
||||
return uri;
|
||||
/*
|
||||
let uri = decodeURIComponent(rawUri);
|
||||
uri = uri.replace(/,/g, '%2C');
|
||||
uri = uri.replace(/'/g, '%27');
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/\(/g, '%28');
|
||||
uri = uri.replace(/\)/g, '%29');
|
||||
uri = uri.replace(/\[/g, '%5B');
|
||||
uri = uri.replace(/\]/g, '%5D');
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/#/g, '%23');
|
||||
//uri = uri.replace(/\//g, '%2F');
|
||||
console.debug({ rawUri, uri });
|
||||
return uri;*/
|
||||
};
|
||||
/**
|
||||
* Format our album objects into a universal format
|
||||
@ -134230,7 +134218,7 @@ var Queue = /*#__PURE__*/function (_React$Component) {
|
||||
className: "current-track__added-from",
|
||||
"data-qa-node": "div",
|
||||
"data-qa-file": "Queue"
|
||||
}, addedFromItems[0].images && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_URILink__WEBPACK_IMPORTED_MODULE_11__["default"], {
|
||||
}, addedFromItems[0].images && addedFromItems[0].uri && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_URILink__WEBPACK_IMPORTED_MODULE_11__["default"], {
|
||||
uri: addedFromItems[0].uri,
|
||||
type: addedFromItems[0].type,
|
||||
className: "current-track__added-from__thumbnail",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1194,6 +1194,8 @@ const MopidyMiddleware = (function () {
|
||||
can_edit: true,
|
||||
});
|
||||
|
||||
console.debug({ playlist })
|
||||
|
||||
if (response.tracks) {
|
||||
request(store, 'library.lookup', { uris: arrayOf('uri', response.tracks) })
|
||||
.then((tracksResponse) => {
|
||||
|
||||
@ -282,14 +282,14 @@ const formatSimpleObjects = function (records = []) {
|
||||
* '/' as this is a URL parameter delimiter
|
||||
* @param {String} uri
|
||||
*/
|
||||
const encodeUri = (rawUri) => {
|
||||
const encodeUri = (rawUri = '') => {
|
||||
let uri = rawUri;
|
||||
uri = uri.replace(/\//g, '%2F');
|
||||
uri = uri.replace(/\?/g, '%3F');
|
||||
uri = uri.replace(/%/g, '%25');
|
||||
//uri = encodeURIComponent(uri);
|
||||
|
||||
return uri;
|
||||
|
||||
//encodeURIComponent(rawUri);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,34 +306,14 @@ const encodeUri = (rawUri) => {
|
||||
*
|
||||
* @param {String} rawUri
|
||||
*/
|
||||
const decodeUri = (rawUri) => {
|
||||
const decodeUri = (rawUri = '') => {
|
||||
let uri = rawUri;
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/%2F/g, '/');
|
||||
uri = uri.replace(/%3F/g, '?');
|
||||
//uri = decodeURIComponent(uri);
|
||||
|
||||
/**
|
||||
* What if we removed encoding completely? It looks like mopidy URIs are encoded to be URL friendly,
|
||||
* except for slashes. So in principle we could just replace slash with %2F but otherwise not use
|
||||
* encode/decodeUriComponent.
|
||||
*/
|
||||
|
||||
return uri;
|
||||
/*
|
||||
let uri = decodeURIComponent(rawUri);
|
||||
uri = uri.replace(/,/g, '%2C');
|
||||
uri = uri.replace(/'/g, '%27');
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/\(/g, '%28');
|
||||
uri = uri.replace(/\)/g, '%29');
|
||||
uri = uri.replace(/\[/g, '%5B');
|
||||
uri = uri.replace(/\]/g, '%5D');
|
||||
uri = uri.replace(/ /g, '%20');
|
||||
uri = uri.replace(/#/g, '%23');
|
||||
//uri = uri.replace(/\//g, '%2F');
|
||||
|
||||
console.debug({ rawUri, uri });
|
||||
return uri;*/
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -173,7 +173,7 @@ class Queue extends React.Component {
|
||||
|
||||
return (
|
||||
<div className="current-track__added-from">
|
||||
{addedFromItems[0].images && (
|
||||
{addedFromItems[0].images && addedFromItems[0].uri && (
|
||||
<URILink
|
||||
uri={addedFromItems[0].uri}
|
||||
type={addedFromItems[0].type}
|
||||
|
||||
Reference in New Issue
Block a user