2019-05-06 07:31:26 -04:00
|
|
|
|
---
|
|
|
|
|
id: bd7158d8c443edefaeb5bd0e
|
|
|
|
|
challengeType: 4
|
2020-09-18 00:11:18 +08:00
|
|
|
|
forumTopicId: 301509
|
2020-10-01 17:54:21 +02:00
|
|
|
|
title: 短网址
|
2019-05-06 07:31:26 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-09-18 00:11:18 +08:00
|
|
|
|
<section id='description'>
|
|
|
|
|
构建一个功能类似于 <a href='https://thread-paper.glitch.me/' target='_blank'>https://thread-paper.glitch.me/</a> 的 JavaScript 全栈应用。
|
|
|
|
|
在开发这个项目时,我们推荐你在 <a href='https://glitch.com/'>Glitch</a> 上编码。编码完成之后,你可以把应用主页的链接复制到屏幕的输入框中,测试你的代码是否能通过项目需求。当然你也可以基于其他的平台来完成自己的项目,只要提供一个公开的主页便于我们测试就行。
|
|
|
|
|
参考示例:你可以通过 <a href='https://glitch.com/#!/import/github/freeCodeCamp/boilerplate-project-urlshortener/'>这个链接</a> 访问在 Glitch 上的项目,或者从 GitHub 上 clone <a href='https://github.com/freeCodeCamp/boilerplate-project-urlshortener/'>这个仓库的代码</a>。如果你使用 Glitch,请记住将项目链接保存到妥当的地方。
|
2019-05-06 07:31:26 -04:00
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Instructions
|
2020-09-18 00:11:18 +08:00
|
|
|
|
<section id='instructions'>
|
2019-05-06 07:31:26 -04:00
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2020-09-18 00:11:18 +08:00
|
|
|
|
- text: 当我传入一个 url 作为参数时,我将在JSON响应中收到缩短的URL。
|
2019-05-06 07:31:26 -04:00
|
|
|
|
testString: ''
|
2020-09-18 00:11:18 +08:00
|
|
|
|
- text: '如果我传入一个无效的链接,则会返回一个包含 “没有遵循如 http://www.example.com 的有效格式” 的错误信息的 JSON 响应。'
|
2019-05-06 07:31:26 -04:00
|
|
|
|
testString: ''
|
2020-09-18 00:11:18 +08:00
|
|
|
|
- text: 当我访问这个短 URL 时, 将重定向到我原来的链接。
|
2019-05-06 07:31:26 -04:00
|
|
|
|
testString: ''
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
2020-09-28 15:18:23 +02:00
|
|
|
|
<section id='challengeSeed'>
|
2019-05-06 07:31:26 -04:00
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
2020-09-18 00:11:18 +08:00
|
|
|
|
/**
|
|
|
|
|
Backend challenges don't need solutions,
|
|
|
|
|
because they would need to be tested against a full working project.
|
|
|
|
|
Please check our contributing guidelines to learn more.
|
|
|
|
|
*/
|
2019-05-06 07:31:26 -04:00
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
2020-09-18 00:11:18 +08:00
|
|
|
|
</section>
|