<p>I'm currently trying to build a URL shortener microservice in Go for FreeCodeCamp, and I need a bit of help. I've tried asking on StackOverflow and the FreeCodeCamp forum but nobody seems willing, or able, to help.</p>
<p>I've got most of my other code running but when I add a url to the end of the api route (i.e. <a href="https://morning-retreat-24523.herokuapp.com/new/https://www.google.com" rel="nofollow">https://morning-retreat-24523.herokuapp.com/new/https://www.google.com</a>) a forward slash gets removed so that it ends up as: <a href="https://morning-retreat-24523.herokuapp.com/new/https:/www.google.com" rel="nofollow">https://morning-retreat-24523.herokuapp.com/new/https:/www.google.com</a> and then throws a '404 page not found' error.</p>
<p>My github repo is here: <a href="https://github.com/AndrewRMorgan/url-shortener" rel="nofollow">https://github.com/AndrewRMorgan/url-shortener</a></p>
<p>Its getting really frustrating, it seems like all the other apps built in node don't seem to need to do anything special to make this work so I suppose I'm just wondering what I might be doing wrong?</p>
<hr/>**评论:**<br/><br/>HectorJ: <pre><p><a href="https://github.com/AndrewRMorgan/url-shortener/pull/1" rel="nofollow">https://github.com/AndrewRMorgan/url-shortener/pull/1</a></p>
<p>Haven't tested it, but that should do the job, I think.</p></pre>philstudent123: <pre><p>Thanks HectorJ, that did the trick. Now I just need to figure out why it's still giving me a 404 error haha.</p></pre>softwaregav: <pre><p>I think I saw this on SO, and they told you the same thing. You need to URL encode the URL you're sending as a parameter. It's probably being parsed differently than you think. I'll check it out when I get home from class.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传