From ebfcb8387a4c2e23be6ea2376fd1b399b7533f54 Mon Sep 17 00:00:00 2001 From: Menci Date: Sat, 15 Apr 2017 17:51:39 +0800 Subject: [PATCH] Fix import problem url error --- modules/problem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/problem.js b/modules/problem.js index eb00df0..fdc9712 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -268,7 +268,7 @@ app.post('/problem/:id/import', async (req, res) => { let url = require('url'); let json = await request({ - uri: url.resolve(req.body.url, 'export'), + uri: req.body.url + (req.body.url.endsWith('/') ? 'export' : '/export'), timeout: 1500, json: true }); @@ -301,7 +301,7 @@ app.post('/problem/:id/import', async (req, res) => { let fs = require('bluebird').promisifyAll(require('fs')); try { - let data = await download(url.resolve(req.body.url, 'download')); + let data = await download(req.body.url + (req.body.url.endsWith('/') ? 'download' : '/download')); await fs.writeFileAsync(tmpFile.path, data); await problem.updateTestdata(tmpFile.path); } catch (e) {