Skip to content

Commit

Permalink
🔧 修改API
Browse files Browse the repository at this point in the history
  • Loading branch information
onee-io committed Jan 7, 2024
1 parent 1f980da commit 7a1352f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ app.get('/:code', async (request, response) => {
response.redirect(originUrl);
});

app.post('/', async (request, response) => {
app.post('/url', async (request, response) => {
const encodedUrl = encodeURI(request.body.url);
if (!/^((https|http)?:\/\/)[^\s]+/.test(encodedUrl)) {
return response.status(400).json({ error: 'Incorrect URL format' }).end();
Expand Down
2 changes: 1 addition & 1 deletion src/services/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import axios from "axios";
* @returns 短链接
*/
const shortUrl = async url => {
const res = await axios.post('/', { url });
const res = await axios.post('/url', { url });
return res.data;
}

Expand Down

0 comments on commit 7a1352f

Please sign in to comment.