[英]Prevent addition of a trailing slash to a URL
我在我的 React Native 應用程序中使用URL API 來方便地為我的請求構造查詢字符串。
我發現這個 API 在 URL 中添加了一個斜杠,這會破壞所有請求。
let uri = new URL('https://example.com/path');
console.log(uri.toString());
// https://example.com/path/
我在瀏覽器(Chromium 87)中進行了一些測試,發現那里不存在這種行為。 它是 React 還是 React Native 的怪癖?
問題是如何防止在 URL 中添加尾隨空格?
嘗試使用
uri.href
而不是uri.toString()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.