Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7343105
D8820.id31799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D8820.id31799.diff
View Options
diff --git a/cypress/e2e/origin-search.cy.js b/cypress/e2e/origin-search.cy.js
--- a/cypress/e2e/origin-search.cy.js
+++ b/cypress/e2e/origin-search.cy.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019-2021 The Software Heritage developers
+ * Copyright (C) 2019-2022 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -311,6 +311,30 @@
}
});
+ it('should encode origin argument in latest visit URL queried by XHR', function() {
+ // origin added in tests data by Python
+ const originUrl = 'https://example.org/project/download.php?version=2.0';
+ cy.intercept(`**/api/1/origin/${encodeURIComponent(originUrl)}/visit/latest/**`)
+ .as('checkOriginVisit');
+
+ doSearch(originUrl);
+
+ cy.wait('@checkOriginVisit');
+
+ cy.get('.swh-search-result-entry')
+ .should('have.length', 1);
+
+ cy.get('.swh-search-result-entry#origin-0 .swh-origin-visit-type')
+ .should('have.text', 'tar');
+
+ cy.get('.swh-search-result-entry#origin-0 td a')
+ .should('have.text', originUrl);
+
+ cy.get('.swh-search-result-entry#origin-0 .swh-visit-status')
+ .should('have.text', 'Archived');
+
+ });
+
context('Test pagination', function() {
it('should not paginate if there are not many results', function() {
// Setup search
diff --git a/swh/web/browse/assets/browse/origin-search.js b/swh/web/browse/assets/browse/origin-search.js
--- a/swh/web/browse/assets/browse/origin-search.js
+++ b/swh/web/browse/assets/browse/origin-search.js
@@ -1,11 +1,11 @@
/**
- * Copyright (C) 2018-2021 The Software Heritage developers
+ * Copyright (C) 2018-2022 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
-import {handleFetchError, errorMessageFromResponse, isArchivedOrigin} from 'utils/functions';
+import {errorMessageFromResponse, handleFetchError, isArchivedOrigin} from 'utils/functions';
const limit = 100;
const linksPrev = [];
@@ -53,7 +53,7 @@
tableRow += '</tr>';
table.append(tableRow);
// get async latest visit snapshot and update visit status icon
- let latestSnapshotUrl = Urls.api_1_origin_visit_latest(origin.url);
+ let latestSnapshotUrl = Urls.api_1_origin_visit_latest(encodeURIComponent(origin.url));
latestSnapshotUrl += '?require_snapshot=true';
promises.push(fetch(latestSnapshotUrl));
}
diff --git a/swh/web/tests/data.py b/swh/web/tests/data.py
--- a/swh/web/tests/data.py
+++ b/swh/web/tests/data.py
@@ -270,6 +270,15 @@
visit_type="tar",
)
+ # origin used in cypress test for origins search
+ _add_origin(
+ storage,
+ search,
+ counters,
+ origin_url="https://example.org/project/download.php?version=2.0",
+ visit_type="tar",
+ )
+
sha1s: Set[Sha1] = set()
directories = set()
revisions = set()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 17 2025, 7:24 PM (7 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216814
Attached To
D8820: browse/origin-search: Ensure to encode origin URL argument in XHR calls
Event Timeline
Log In to Comment