Comments (30)
Without any escaping as long as there is not a # it works
Using encodeURIComponet break everything, but if you were to unencode /
it would probably work
Using encodeURI break nothing, works just as well as not escaping
Using escape breaks spacial Unicode characters
encodeURI does not touch these:
A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #
the only characters that look to break this are # and ?
from music-folder-player.
Does it do any harm then? I have a folder #
for all artist names starting with numbers or special characters. If I don't use encodeURIComponent, it won't play (it sees it as an anchor, instead of a folder). Of course, I can only replace #
, but I wasn't sure if any other special chars did the same.
from music-folder-player.
The problem it is escapes forward slashes so it will not work with sub folders
this is form my firefox console
from music-folder-player.
Forward slashes are used on a Windows HTTP server?
from music-folder-player.
I am using a apache2 on my linux server: https://imgur.com/a/5CtPA
Did you have any issues with my version working?
from music-folder-player.
does using the escape function instead work for you, that did not break it for me?
audio.src = escape(path);
from music-folder-player.
Strange, I thought the behavior of the deprecated escape()
would mimic encodeURI()
or encodeURIComponent()
, but apparently it's a different flavor altogether. escape()
works just fine over here, so if it also works in your use case, it's the best option. Thanks!
Apart from this, I also need to add a few lines of error handling when playback fails. I just want it to mark the non-played item and continue with the next, since a party player that stops playing instantly becomes a party pooper.
from music-folder-player.
audio.src = encodeURI(path);
also works for me
from music-folder-player.
Not for me in the #
case, so escape()
is best :-)
from music-folder-player.
Did you have this issue is my version?
from music-folder-player.
Yeah, I did. Back then, I just added s.src=file.replace('#', '%23');
.
from music-folder-player.
from music-folder-player.
- Prevent encoding of
\
inaudio.src
for Apache servers
that is the wrong slash
from music-folder-player.
from music-folder-player.
escape seems to break it with some unicode characters, here is one for you to try: 月
from music-folder-player.
Using encodeURI seems to to not break anything here
encodeURIComponent is used for parameters like this
http://example.com/path/to/file?opt='+encodeURIComponent(string)+'&'+encodeURIComponent(string2)
from music-folder-player.
I guess we should use this:
encodeURI(FILE_PATH).replace(/#/g,'%23');
from music-folder-player.
from music-folder-player.
Wow, that's a thorough investigation. (Probably) definitively fixed in 1.0.2 now :-)
from music-folder-player.
s.replace('#', '%23').replace('?', '%3F');
but what if there is more than one?
function safeURI(src){
return encodeURI(src).replace(/#/g,'%23').replace(/\?/g,'%3F');
}
I feel like there is a way to use replace only once...
from music-folder-player.
Dang, I need to get some sleep, not focused at all anymore.,, Either way, I feel using RegExp will inadvertedly introduce a whole new can of worms with RegExp's metacharacters, so simply using return s.split('#').join('%23').split('?').join('%3F');
is best for this occasion imho. I found my suspicion is documented on StackOverflow, too.
This solution isn't fast, but occurrences will be very limited anyway, so it shouldn't delay the script much at all.
from music-folder-player.
StackOverflow link please
from music-folder-player.
There's a way around it, of course, but I'd rather keep the code more legible. I genuinely hate RegExp, because I keep being awed by its power while stunned and frustrated by its pickyness and lack of intuitiveness :-P
from music-folder-player.
Knew there was a way to only use replace once
function safeURI(src){
return encodeURI(src).replace(/[(#\?]/g,function(char){return escape(char);});
}
There are 10 kinds of people who understand regular expressions: them and us
from music-folder-player.
from music-folder-player.
encodeURI is to be on the safe side
encodeURI is intended to encode a entire url, it does not target ?, =, &, and # as these special url chars
?
is used to send parameters to a server
=
is used to separate parameters names from values
&
is used to separate separate parameters
#
is used for scrolling to elements on a page based on element IDs
I think we could escape both = and &, but browsers know if there has not been a ? symbol they are not being used for parameters
function safeURI(src){return encodeURI(src).replace(/[(\?=&#]/g,function(char){return escape(char);});}
In theory we should be able to use encode uri component and unescape every / if we do not want to escape a few more chars our self
function safeURI(src){return encodeURIComponent(src).replace(/%2F/g,'/');}
If this is used on a full link you need to decode : also
function safeURI(src){return encodeURIComponent(src).replace(/(%2F|%3A)/g,function(str){return decodeURIComponent(str);}); }
function safeURI(src){
// escape additional chars method
return encodeURI(src).replace(/[(\?=&#]/g,function(char){return escape(char);});
// unescape necessary character
return encodeURIComponent(src).replace(/%2F/g,'/');
// unescape multiple chars to be safe
return encodeURIComponent(src).replace(/(%2F|%3A)/g,function(str){return decodeURIComponent(str);});
}
And with that my regex cheat sheet has been consumed
from music-folder-player.
config is null; easy fix; only need to add 4 chars
I do not think that was a waterfox issue, it was a there is no config data yet issue
from music-folder-player.
True, but there wasn't any in Vivaldi either.
from music-folder-player.
firefox should behave the same, the only way for it not to is if the config option has not been set
it a very inconvenient to debug that part as it is set to save the config on page leave, so even if you clear it then reload it saves it and you do not get a cleran config
if you used the same config name i did in your version on the same server both pages share the same config data, if you used Vivaldi on your project then loaded mine on the same server you had a exist config that was not null
also according to a scratch pad test firefox would get this error also as this returns null:
JSON.parse(localStorage.getItem("someFakeStorageName-"+Math.random()))
if that does not return null the browser does not follow the standard
from music-folder-player.
I waited for Cookies Exterminator to clean up cookies & LS, but I guess it didn't take those instances. Sorry to have misinformed you.
Oh and no, I'm not using the same config name in my project.
from music-folder-player.
Related Issues (20)
- Album art HOT 16
- music.ini library configure HOT 9
- Random play HOT 5
- Search as you type + 1 HOT 4
- black screen HOT 5
- music.ini.template HOT 1
- feature request cached library HOT 17
- Files don't play if there is a % in the folder path. HOT 7
- [Firefox mobile] Drag 'n drop in playlist
- Docker HOT 5
- Error im music.js HOT 2
- Problems on new install HOT 13
- Search problems on iPhone HOT 6
- "Copy Song Link Clipboard" without feedback. HOT 7
- Display "Artist - Song name" in player from ID3 Tag HOT 3
- How to add multiple source paths to music folder? HOT 2
- Uncaught TypeError: Cannot read properties of undefined (reading '1') HOT 1
- No Show "Playlist Option" Up HOT 2
- No Showing "Log Change Focuscolor" HOT 2
- Images are not rendering in the read.me HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from music-folder-player.