Merge pull request from mei23/mei-preview

Fix url preview
This commit is contained in:
syuilo 2018-05-10 06:36:19 +09:00 committed by GitHub
commit a4ed163b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions
src
client/app/common/views/components
server/web

View file

@ -45,7 +45,7 @@ export default Vue.extend({
} else if (url.hostname == 'youtu.be') {
this.youtubeId = url.pathname;
} else {
fetch('/url?url=' + this.url).then(res => {
fetch('/url?url=' + encodeURIComponent(this.url)).then(res => {
res.json().then(info => {
this.title = info.title;
this.description = info.description;

View file

@ -14,8 +14,8 @@ module.exports = async (ctx: Koa.Context) => {
function wrap(url: string): string {
return url != null
? url.startsWith('https://')
? url.startsWith('https://') || url.startsWith('data:')
? url
: `https://images.weserv.nl/?url=${url.replace(/^http:\/\//, '')}`
: `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, ''))}`
: null;
}